	var NYJobMap = {
		/*D1:[
			{isName: "Perform a Hit (1.200)", isJobID: 37, isTab: 1, isCity: 1, isCost: 5, isTheXP: 6},
			{isName: "Grow Your Family (1.250)", isJobID: 8, isTab: 1, isCity: 1, isCost: 4, isTheXP: 5},
			{isName: "Collect Protection Money (1.333)", isJobID: 5, isTab: 1, isCity: 1, isCost: 3, isTheXP: 4},
			{isName: "Rob the Warehouse (1.000)", isJobID: 4, isTab: 1, isCity: 1, isCost: 3, isTheXP: 3},
			{isName: "Rough Up Dealers (1.000)", isJobID: 3, isTab: 1, isCity: 1, isCost: 3, isTheXP: 3},
			{isName: "Rob a Drug Runner (1.000)", isJobID: 2, isTab: 1, isCity: 1, isCost: 2, isTheXP: 2},
			{isName: "Chase Away Thugs (1.000)", isJobID: 1, isTab: 1, isCity: 1, isCost: 1, isTheXP: 1}
		],*/
		D2:[
			{isName: "Mugging (1.0000)", isJobID: 6, isTab: 2, isCity: 1},
			{isName: "Auto Theft (1.3333)", isJobID: 7, isTab: 2, isCity: 1},
			{isName: "Take Out a Rogue Cop (1.3333)", isJobID: 9, isTab: 2, isCity: 1},
			{isName: "Collect on a Loan (1.2500)", isJobID: 10, isTab: 2, isCity: 1},
			{isName: "Bank Heist (1.6667)", isJobID: 11, isTab: 2, isCity: 1},
			{isName: "Jewelry Store Job (1.7143)", isJobID: 12, isTab: 2, isCity: 1},
			{isName: "Hijack a Semi (1.7143)", isJobID: 38, isTab: 2, isCity: 1}
		],	
		D3:[
			{isName: "Destroy Enemy Mob Hideout (1.2000)", isJobID: 13, isTab: 3, isCity: 1},
			{isName: "Kill a Protected Snitch (1.2000)", isJobID: 14, isTab: 3, isCity: 1},
			{isName: "Bust a Made Man Out of Prison (1.2000)", isJobID: 15, isTab: 3, isCity: 1},
			{isName: "Asian Museum Break-in (1.3333)", isJobID: 16, isTab: 3, isCity: 1},
			{isName: "Fight a Haitian Gang (1.6000)", isJobID: 17, isTab: 3, isCity: 1},
			{isName: "Clip the Irish Mob's Local Enforcer (1.4444)", isJobID: 39, isTab: 3, isCity: 1},
			{isName: "Steal a Tanker Truck (1.2857)", isJobID: 40, isTab: 3, isCity: 1}
		],
		D4:[
			{isName: "Federal Reserve Raid (1.5909)", isJobID: 18, isTab: 4, isCity: 1},
			{isName: "Smuggle Thai Gems (1.5625)", isJobID: 19, isTab: 4, isCity: 1},
			{isName: "Liquor Smuggling (1.4815)", isJobID: 22, isTab: 4, isCity: 1},
			{isName: "Run Illegal Poker Game (2.1111)", isJobID: 26, isTab: 4, isCity: 1},
			{isName: "Wiretap the Cops (1.8889)", isJobID: 28, isTab: 4, isCity: 1},
			{isName: "Rob an Electronics Store (1.4286)", isJobID: 41, isTab: 4, isCity: 1},
			{isName: "Burn Down a Tenement (1.5625)", isJobID: 42, isTab: 4, isCity: 1},
			{isName: "Distill Some Liquor (1.5556)", isJobID: 23, isTab: 4, isCity: 1},
			{isName: "Manufacture Tokens (1.5556)", isJobID: 24, isTab: 4, isCity: 1},
			{isName: "Get Cheating Deck (1.5556)", isJobID: 25, isTab: 4, isCity: 1},
			{isName: "Overtake Phone Central (1.5556)", isJobID: 27, isTab: 4, isCity: 1}
		],
		D5:[
			{isName: "Repel the Yakuza (1.8182)", isJobID: 29, isTab: 5, isCity: 1},
			{isName: "Disrupt Rival Smuggling Ring (1.7692)", isJobID: 30, isTab: 5, isCity: 1},
			{isName: "Invade Tong-controlled Neighborhood (1.5909)", isJobID: 31, isTab: 5, isCity: 1},
			{isName: "Sell Guns to the Russian Mob (1.8182)", isJobID: 32, isTab: 5, isCity: 1},
			{isName: "Protect your City against a Rival Family (1.8710)", isJobID: 33, isTab: 5, isCity: 1},
			{isName: "Assassinate a Political Figure (1.8710)", isJobID: 34, isTab: 5, isCity: 1},
			{isName: "Exterminate a Rival Family (1.8611)", isJobID: 35, isTab: 5, isCity: 1},
			{isName: "Obtain Compromising Photos (1.4800)", isJobID: 43, isTab: 5, isCity: 1},
			{isName: "Frame a Rival Capo (1.6522)", isJobID: 44, isTab: 5, isCity: 1}
		],
		D6:[
			{isName: "Steal an Air Freight Delivery (1.4643)", isJobID: 45, isTab: 6, isCity: 1},
			{isName: "Run a Biker Gang Out of Town (1.4839)", isJobID: 46, isTab: 6, isCity: 1},
			{isName: "Flip a Snitch (1.5909)", isJobID: 47, isTab: 6, isCity: 1},
			{isName: "Steal Bank Records (1.5185)", isJobID: 48, isTab: 6, isCity: 1},
			{isName: "Loot the Police Impound Lot (1.2778)", isJobID: 49, isTab: 6, isCity: 1},
			{isName: "Recruit a Rival Crew Member (1.6667)", isJobID: 50, isTab: 6, isCity: 1},
			{isName: "Dodge an FBI Tail (1.6667)", isJobID: 51, isTab: 6, isCity: 1},
			{isName: "Whack a Rival Crew Leader (1.7600)", isJobID: 52, isTab: 6, isCity: 1}
		],
		D7:[
			{isName: "Influence a Harbor Official (1.6444)", isJobID: 53, isTab: 7, isCity: 1},
			{isName: "Move Stolen Merchandise (1.8125)", isJobID: 54, isTab: 7, isCity: 1},
			{isName: "Snuff a Rat (1.8205)", isJobID: 55, isTab: 7, isCity: 1},
			{isName: "Help a Fugitive Flee the Country (1.8333)", isJobID: 56, isTab: 7, isCity: 1},
			{isName: "Dispose of a Body (1.8636)", isJobID: 57, isTab: 7, isCity: 1},
			{isName: "Ransom a Businessman's Kids (1.5000)", isJobID: 58, isTab: 7, isCity: 1},
			{isName: "Fix the Big Game (1.5333)", isJobID: 59, isTab: 7, isCity: 1},
			{isName: "Steal an Arms Shipment (1.8750)", isJobID: 60, isTab: 7, isCity: 1}
		],
		D8:[
			{isName: "Extort a Corrupt Judge (1.9524)", isJobID: 61, isTab: 8, isCity: 1},
			{isName: "Embezzle Funds Through a Phony Company (1.8000)", isJobID: 62, isTab: 8, isCity: 1},
			{isName: "Break Into the Armory (1.5333)", isJobID: 63, isTab: 8, isCity: 1},
			{isName: "Rip Off the Armenian Mob (1.7333)", isJobID: 64, isTab: 8, isCity: 1},
			{isName: "Muscle in on a Triad Operation (1.9500)", isJobID: 65, isTab: 8, isCity: 1},
			{isName: "Ambush a Rival at a Sit Down (1.8776)", isJobID: 66, isTab: 8, isCity: 1},
			{isName: "Order a Hit on a Public Official (2.0323)", isJobID: 67, isTab: 8, isCity: 1},
			{isName: "Take Over an Identity Theft Ring (1.8750)", isJobID: 68, isTab: 8, isCity: 1}
		],
		D9:[
			{isName: "Settle a Beef... Permanently (1.9167)", isJobID: 69, isTab: 9, isCity: 1},
			{isName: "Buy Off a Federal Agent (2.1613)", isJobID: 70, isTab: 9, isCity: 1},
			{isName: "Make a Deal with the Mexican Cartel (1.9167)", isJobID: 71, isTab: 9, isCity: 1},
			{isName: "Blackmail the District Attorney (1.8974)", isJobID: 72, isTab: 9, isCity: 1},
			{isName: "Shake Down a City Council Member (2.0000)", isJobID: 73, isTab: 9, isCity: 1},
			{isName: "Make Arrangements for a Visiting Don (1.9167)", isJobID: 74, isTab: 9, isCity: 1},
			{isName: "Take Control of a Casino (1.9206)", isJobID: 75, isTab: 9, isCity: 1},
			{isName: "Travel to the Old Country (1.9565)", isJobID: 76, isTab: 9, isCity: 1}
		]
	};
	
	var BRLJobMap = {
		D1:[
			{isName: "Scope Out the Financial District (1.152)", isJobID: 1, isTab: 1, isCity: 7},
			{isName: "Set Up Your Operation in a Renovated Skyscraper (1.152)", isJobID: 2, isTab: 1, isCity: 7},
			{isName: "Ask an Informant About Local Crime Activity (1.163)", isJobID: 3, isTab: 1, isCity: 7},
			{isName: "Steal Artwork from the Paco Imperial (1.531)", isJobID: 4, isTab: 1, isCity: 7},
			{isName: "Bribe a Corporate Executive (1.152)", isJobID: 5, isTab: 1, isCity: 7},
			{isName: "Ambush a Group of Neo-Imperium (1.531)", isJobID: 6, isTab: 1, isCity: 7},
			{isName: "Destroy a Bondinho Tram (1.136)", isJobID: 7, isTab: 1, isCity: 7},
			{isName: "Blackmail a Cathedral Representative (1.146)", isJobID: 8, isTab: 1, isCity: 7},
			{isName: "Run a Collection Plate Con (1.378)", isJobID: 9, isTab: 1, isCity: 7},
			{isName: "Track Down Lieutenant Sandoval (1.598)", isJobID: 10, isTab: 1, isCity: 7},
			{isName: "Assassinate a Politician at a Museum Gala (1.47)", isJobID: 11, isTab: 1, isCity: 7}
		],
		D2:[
			{isName: "Meet a Contact at Mosqueiro (1.47)", isJobID: 13, isTab: 2, isCity: 7},
			{isName: "Impersonate a Wealthy Entrepreneur (1.47)", isJobID: 14, isTab: 2, isCity: 7},
			{isName: "Dispose of a Police Chief (1.705)", isJobID: 15, isTab: 2, isCity: 7},
			{isName: "Intimidate the Local Crime Ring (1.957)", isJobID: 16, isTab: 2, isCity: 7},
			{isName: "Track Down Neo-Imperium Members (1.705)", isJobID: 17, isTab: 2, isCity: 7},
			{isName: "Smuggle a Shipment Through Aeroporto de Belem (1.649)", isJobID: 18, isTab: 2, isCity: 7},
			{isName: "Steal the Plans (1.77)", isJobID: 19, isTab: 2, isCity: 7},
			{isName: "Burn Down a Jungle Hideout (1.899)", isJobID: 20, isTab: 2, isCity: 7},
			{isName: "Establish a Spy Ring of Belem Fishermen (1.818)", isJobID: 21, isTab: 2, isCity: 7},
			{isName: "Gun Down Kidnappers (2.027)", isJobID: 22, isTab: 2, isCity: 7},
			{isName: "Capture a Neo-Imperium Captain (1.862)", isJobID: 23, isTab: 2, isCity: 7},
			{isName: "Bribe a City Official (1.862)", isJobID: 24, isTab: 2, isCity: 7}
		],
		D3:[
			{isName: "Blackmail a City Official (1.7)", isJobID: 25, isTab: 3, isCity: 7},
			{isName: "Gather Intel from Street Rats (1.572)", isJobID: 26, isTab: 3, isCity: 7},
			{isName: "Assassinate a Neo-Imperium Spokesman (1.619)", isJobID: 27, isTab: 3, isCity: 7},
			{isName: "Bribe a Police Commandant (1.661)", isJobID: 28, isTab: 3, isCity: 7},
			{isName: "Pilfer from a Rebel Supply House (1.619)", isJobID: 29, isTab: 3, isCity: 7},
			{isName: "Locate a Rebel Outpost (1.665)", isJobID: 30, isTab: 3, isCity: 7},
			{isName: "Intercept a Rebel Convoy (1.742)", isJobID: 31, isTab: 3, isCity: 7},
			{isName: "Take Out a Rebel Lookout (1.631)", isJobID: 32, isTab: 3, isCity: 7},
			{isName: "Create a Diversion in the Jungle (1.67)", isJobID: 33, isTab: 3, isCity: 7},
			{isName: "Blow Up a Munitions Dump (1.602)", isJobID: 34, isTab: 3, isCity: 7},
			{isName: "Open Fire on Rebel Fighters (1.701)", isJobID: 35, isTab: 3, isCity: 7},
			{isName: "Rescue a Hostage (1.637)", isJobID: 36, isTab: 3, isCity: 7}
		],
		D4:[
			{isName: "Move to a Sao Paolo Safe House (1.702)", isJobID: 37, isTab: 4, isCity: 7},
			{isName: "Transport a Drug Shipment (1.731)", isJobID: 38, isTab: 4, isCity: 7},
			{isName: "Push Over a Gun Runner (1.827)", isJobID: 39, isTab: 4, isCity: 7},
			{isName: "Pass Along a Bribe (1.757)", isJobID: 40, isTab: 4, isCity: 7},
			{isName: "Contact a Comando do Candiru Agent (1.87)", isJobID: 41, isTab: 4, isCity: 7},
			{isName: "Scout Out the City (1.781)", isJobID: 42, isTab: 4, isCity: 7},
			{isName: "Rob a Jewelry Store (1.889)", isJobID: 43, isTab: 4, isCity: 7},
			{isName: "Burn Down a Slum Building (1.907)", isJobID: 44, isTab: 4, isCity: 7},
			{isName: "Escape a Police Pursuit (1.824)", isJobID: 45, isTab: 4, isCity: 7},
			{isName: "Demolish a Rooftop Helipad (1.855)", isJobID: 46, isTab: 4, isCity: 7},
			{isName: "Wipe Out a Favela Street Gang (1.873)", isJobID: 47, isTab: 4, isCity: 7},
			{isName: "Interrogate a Neo-Imperium Supporter (1.889)", isJobID: 48, isTab: 4, isCity: 7}
		],
		D5:[
			{isName: "Smuggle Weapons Down the River to a Recife Port (1.843)", isJobID: 49, isTab: 5, isCity: 7},
			{isName: "Negotiate a Sit-Down with the Comando do Candiru (1.813)", isJobID: 50, isTab: 5, isCity: 7},
			{isName: "Auction Off a Rival's Private Island (1.788)", isJobID: 51, isTab: 5, isCity: 7},
			{isName: "Detonate an Ethanol Shipment (1.859)", isJobID: 52, isTab: 5, isCity: 7},
			{isName: "Create a Shark Scare (1.832)", isJobID: 53, isTab: 5, isCity: 7},
			{isName: "Steal Confidential Medical Records (1.937)", isJobID: 54, isTab: 5, isCity: 7},
			{isName: "Blackmail a University Instructor (1.996)", isJobID: 55, isTab: 5, isCity: 7},
			{isName: "Raid a Biochemist's Lab (1.962)", isJobID: 56, isTab: 5, isCity: 7},
			{isName: "Sink a Cargo Ship in Port (1.764)", isJobID: 57, isTab: 5, isCity: 7},
			{isName: "Take Over a Shipyard (1.943)", isJobID: 58, isTab: 5, isCity: 7},
			{isName: "Give Chase to the Neo-Imperium (1.984)", isJobID: 59, isTab: 5, isCity: 7}
		],
		D6:[
			{isName: "Shake Down Some Locals For Information (2.006)", isJobID: 60, isTab: 6, isCity: 7},
			{isName: "Discover Connections to Local Gangs (2.021)", isJobID: 61, isTab: 6, isCity: 7},
			{isName: "Bribe a News Network Executive (2.061)", isJobID: 62, isTab: 6, isCity: 7},
			{isName: "Make an Announcement on a Local TV Network (1.905)", isJobID: 63, isTab: 6, isCity: 7},
			{isName: "Convince The Locals Of Your Good Intentions (2.01)", isJobID: 64, isTab: 6, isCity: 7},
			{isName: "Hunt Down The Revolucao Vermelho's Affiliates (1.937)", isJobID: 65, isTab: 6, isCity: 7},
			{isName: "Bust Up a Local Drug Ring (1.971)", isJobID: 66, isTab: 6, isCity: 7},
			{isName: "Delay a Police Patrol (2.04)", isJobID: 67, isTab: 6, isCity: 7},
			{isName: "Hijack a Fuel Truck (1.971)", isJobID: 68, isTab: 6, isCity: 7},
			{isName: "Offer Protection to a Franchise Business (1.996)", isJobID: 69, isTab: 6, isCity: 7},
			{isName: "Execute a Slum Gang Leader (2.086)", isJobID: 70, isTab: 6, isCity: 7},
			{isName: "Make a Direct Assault on the RV Base (2.099)", isJobID: 71, isTab: 6, isCity: 7}
		],
		D7:[
			{isName: "Mobilize Your Operation (2.006)", isJobID: 72, isTab: 7, isCity: 7},
			{isName: "Generate Revenue for Your Cause (2.079)", isJobID: 73, isTab: 7, isCity: 7},
			{isName: "Find Proof of Police Corruption (2.04)", isJobID: 74, isTab: 7, isCity: 7},
			{isName: "Rendezvous with Comando do Candiru Agents (2.079)", isJobID: 75, isTab: 7, isCity: 7},
			{isName: "Bribe a Carnival Director (2.079)", isJobID: 76, isTab: 7, isCity: 7},
			{isName: "Take Advantage of a Distracted Crowd (2.04)", isJobID: 77, isTab: 7, isCity: 7},
			{isName: "Blend in with a Group of Float Performers (2.015)", isJobID: 78, isTab: 7, isCity: 7},
			{isName: "Assassinate the Guest of Honor (2.058)", isJobID: 79, isTab: 7, isCity: 7},
			{isName: "Cut the RV's Purse Strings (2.006)", isJobID: 80, isTab: 7, isCity: 7},
			{isName: "Tail a Group of RV to Their Base (2.04)", isJobID: 81, isTab: 7, isCity: 7},
			{isName: "Remove the Police Protection (2.015)", isJobID: 82, isTab: 7, isCity: 7},
			{isName: "Demolish an RV stronghold (2.065)", isJobID: 83, isTab: 7, isCity: 7}
		],
		D8:[
			{isName: "Prepare an Ambush for a Neo-Imperium Sect (2.015)", isJobID: 84, isTab: 8, isCity: 7},
			{isName: "Interrogate Comando do Condiru Agents (2.05)", isJobID: 85, isTab: 8, isCity: 7},
			{isName: "Acquire Funds for Taubate Operations (2.086)", isJobID: 86, isTab: 8, isCity: 7},
			{isName: "Bribe a Taubate Prison Worker (2.221)", isJobID: 87, isTab: 8, isCity: 7},
			{isName: "Infiltrate Taubate Prison (2.05)", isJobID: 88, isTab: 8, isCity: 7},
			{isName: "Arrange for Prisoner Transfers (1.974)", isJobID: 89, isTab: 8, isCity: 7},
			{isName: "Disable Police Emergency Response (2.04)", isJobID: 90, isTab: 8, isCity: 7},
			{isName: "Cause Civilian Panic (2.099)", isJobID: 91, isTab: 8, isCity: 7},
			{isName: "Scout For Potential (2.065)", isJobID: 92, isTab: 8, isCity: 7},
			{isName: "Break Mafia Members Out of Taubate (2.024)", isJobID: 93, isTab: 8, isCity: 7},
			{isName: "Destroy the Neo-Imperium's Cover Operations (2.072)", isJobID: 94, isTab: 8, isCity: 7},
			{isName: "Assassinate the Neo-Imperium's Primary Heads (2.191)", isJobID: 95, isTab: 8, isCity: 7}
		]
	};

	var CHIJobMap = {
		D1:[
			{isName: "Meet With the South Gang Family (1.333)", isJobID: 1, isTab: 1, isCity: 8},
			{isName: "Drive North of the Border (1.333)", isJobID: 2, isTab: 1, isCity: 8},
			{isName: "Set Up a Rum Running Operation (1.25)", isJobID: 3, isTab: 1, isCity: 8},
			{isName: "Smuggle a Shipment Back to Chicago (1.75)", isJobID: 4, isTab: 1, isCity: 8},
			{isName: "Break Into Guido Pantucci's Warehouse (1.25)", isJobID: 5, isTab: 1, isCity: 8},
			{isName: "Dodge the Guards (1.75)", isJobID: 6, isTab: 1, isCity: 8},
			{isName: "Get Rid of Pantucci (1.167)", isJobID: 7, isTab: 1, isCity: 8},
			{isName: "Dispose of the Bodies (1.333)", isJobID: 8, isTab: 1, isCity: 8}
		],
		D2:[
			{isName: "Run an illegal Establishment (1.933)", isJobID: 9, isTab: 2, isCity: 8},
			{isName: "Secure Hooch to Sell in Your Joint (2.167)", isJobID: 10, isTab: 2, isCity: 8},
			{isName: "Recruit Loyal Gunmen (1.611)", isJobID: 11, isTab: 2, isCity: 8},
			{isName: "Case Warehouses on the North Side (2.143)", isJobID: 12, isTab: 2, isCity: 8},
			{isName: "Expose a Treachery in Your Family (1.625)", isJobID: 13, isTab: 2, isCity: 8},
			{isName: "Cripple the Colosimo Clan's Assets (1.926)", isJobID: 14, isTab: 2, isCity: 8},
			{isName: "Ambush the Don's Limo (1.939)", isJobID: 15, isTab: 2, isCity: 8},
			{isName: "Get the Respect You Deserve (1.972)", isJobID: 16, isTab: 2, isCity: 8}
		],
		D3:[ 
			{isName: "Move Smuggled Liquor (1.889)", isJobID: 17, isTab: 3, isCity: 8},
			{isName: "Collect Income From Your Establishments (1.974)", isJobID: 18, isTab: 3, isCity: 8},
			{isName: "Stuff Local Cop's Pockets With Greens (1.905)", isJobID: 19, isTab: 3, isCity: 8},
			{isName: "Organize a Private Party (1.926)", isJobID: 20, isTab: 3, isCity: 8},
			{isName: "Evade an Ambush (1.852)", isJobID: 21, isTab: 3, isCity: 8},
			{isName: "Uncover a Plot Against You (1.868)", isJobID: 22, isTab: 3, isCity: 8},
			{isName: "Order a Hit on Disloyal Associates (1.938)", isJobID: 23, isTab: 3, isCity: 8},
			{isName: "Put Brother Franky in Concrete Shoes (1.882)", isJobID: 24, isTab: 3, isCity: 8}
		],
		D4:[
			{isName: "Set Up a Distillery in Cicero (1.662)", isJobID: 25, isTab: 4, isCity: 8},
			{isName: "Meet With a Mayoral Candidate (1.734)", isJobID: 26, isTab: 4, isCity: 8},
			{isName: "Threaten Voters at Polling Stations (1.696)", isJobID: 27, isTab: 4, isCity: 8},
			{isName: "Get Puppet Mayor Elected (1.722)", isJobID: 28, isTab: 4, isCity: 8},
			{isName: "Escape a Federal Agents Raid on Your Distillery (1.711)", isJobID: 29, isTab: 4, isCity: 8},
			{isName: "Find Out About Mayor's Dealings With the Bureau (1.667)", isJobID: 30, isTab: 4, isCity: 8},
			{isName: "Blackmail a Prohibition Bureau Top Agent (1.824)", isJobID: 31, isTab: 4, isCity: 8},
			{isName: "Frame Mayor in a Political Scandal (1.867)", isJobID: 32, isTab: 4, isCity: 8}
		],
		D5:[ 
			{isName: "Travel South to the Caribbean (1.965)", isJobID: 33, isTab: 5, isCity: 8},
			{isName: "Set Up a Rum Running Base of Operation (1.84)", isJobID: 34, isTab: 5, isCity: 8},
			{isName: "Monitor Coast Guard Patrols (1.957)", isJobID: 35, isTab: 5, isCity: 8},
			{isName: "Hijack a Rival Ship (1.743)", isJobID: 36, isTab: 5, isCity: 8},
			{isName: "Eliminate the Competition (1.867)", isJobID: 37, isTab: 5, isCity: 8},
			{isName: "Comb the Beach for Scraps (1.831)", isJobID: 38, isTab: 5, isCity: 8},
			{isName: "Ferry Customers Across the Rum Line (1.965)", isJobID: 39, isTab: 5, isCity: 8},
			{isName: "Host Happy Hours on Board (1.939)", isJobID: 40, isTab: 5, isCity: 8}
		],
		D6:[
			{isName: "Catch a Saboteur (1.974)", isJobID: 41, isTab: 6, isCity: 8},
			{isName: "Storm Into a North Side Gang Brewery (2.078)", isJobID: 42, isTab: 6, isCity: 8},
			{isName: "Dodge a Firebombing on Your Headquarters (1.982)", isJobID: 43, isTab: 6, isCity: 8},
			{isName: "Salvage Your Valuables From a Blazing Fire (1.948)", isJobID: 44, isTab: 6, isCity: 8},
			{isName: "Call for a Truce With the North Siders (1.988)", isJobID: 45, isTab: 6, isCity: 8},
			{isName: "Narrowly Survive an Assassination Attempt (1.957)", isJobID: 46, isTab: 6, isCity: 8},
			{isName: "Plan a Decisive Blow Against the North Siders (1.988)", isJobID: 47, isTab: 6, isCity: 8},
			{isName: "Flee the Scene Before the Police Arrive (1.963)", isJobID: 48, isTab: 6, isCity: 8}
		]
	};
	
	var LONJobMap = {
		D1:[
			{isName: "Claim Your Winnings After The Match (1.281)", isJobID: 1, isTab: 1, isCity: 9},
			{isName: "Fight Off The Thugs (1.496)", isJobID: 2, isTab: 1, isCity: 9},
			{isName: "Discuss Your Options With The Betting Mafia (1.496)", isJobID: 3, isTab: 1, isCity: 9},
			{isName: "Persuade \"The Kid\" To Throw The Championship Fight (1.281)", isJobID: 4, isTab: 1, isCity: 9},
			{isName: "Spike \"The Kid's\" Energy Drink With A Neurotoxin (1.602)", isJobID: 5, isTab: 1, isCity: 9},
			{isName: "Bet On \"The Kid\" Losing The Championship Fight (1.423)", isJobID: 6, isTab: 1, isCity: 9},
			{isName: "Watch The Fight (1.373)", isJobID: 7, isTab: 1, isCity: 9},
			{isName: "Collect Your Take (1.707)", isJobID: 8, isTab: 1, isCity: 9}
		],
		D2:[
			{isName: "Force An Immigrant Family From Their Home (1.373)", isJobID: 9, isTab: 2, isCity: 9},
			{isName: "Meet The Land Mafia To Collect Your Take (1.707)", isJobID: 10, isTab: 2, isCity: 9},
			{isName: "Intimidate The New Celebrity Residents (1.602)", isJobID: 11, isTab: 2, isCity: 9},
			{isName: "Case The Nouvelle Vague Art Gallery (1.868)", isJobID: 12, isTab: 2, isCity: 9},
			{isName: "Destroy The Rare East End Works Painting (1.778)", isJobID: 13, isTab: 2, isCity: 9},
			{isName: "Burn Down A Brand New Condo (1.815)", isJobID: 14, isTab: 2, isCity: 9},
			{isName: "Collect Your Take From The Construction Firms (2.134)", isJobID: 15, isTab: 2, isCity: 9},
			{isName: "Leave The East End (1.957)", isJobID: 16, isTab: 2, isCity: 9}
		],
		D3:[ 
			{isName: "Write About The Mysterious Shooting (1.887)", isJobID: 17, isTab: 3, isCity: 9},
			{isName: "Work With The PI At The Crime Scene (1.829)", isJobID: 18, isTab: 3, isCity: 9},
			{isName: "Approach The Police With Leads (2.051)", isJobID: 19, isTab: 3, isCity: 9},
			{isName: "Search For A Trail (1.921)", isJobID: 20, isTab: 3, isCity: 9},
			{isName: "Threaten To Expose The Royal (1.849)", isJobID: 21, isTab: 3, isCity: 9},
			{isName: "Lay A Trap For The Royal (1.867)", isJobID: 22, isTab: 3, isCity: 9},
			{isName: "Tell The Editor The Truth (1.82)", isJobID: 23, isTab: 3, isCity: 9},
			{isName: "Publish False Story Under Threat (1.867)", isJobID: 24, isTab: 3, isCity: 9}
		],
		D4:[
			{isName: "Accept The Offer Made By The Russians (1.778)", isJobID: 25, isTab: 4, isCity: 9},
			{isName: "Provide Insider Information On Your Gang (2.074)", isJobID: 26, isTab: 4, isCity: 9},
			{isName: "Escape The Hitmen After Being Discovered (1.92)", isJobID: 27, isTab: 4, isCity: 9},
			{isName: "Take Shelter In A Warehouse (2.021)", isJobID: 28, isTab: 4, isCity: 9},
			{isName: "Fake Your Own Death (1.88)", isJobID: 29, isTab: 4, isCity: 9},
			{isName: "Create A Russian Identity (2.081)", isJobID: 30, isTab: 4, isCity: 9},
			{isName: "Eliminate Your Gang With The Russians (1.93)", isJobID: 31, isTab: 4, isCity: 9},
			{isName: "Run The Racket (1.981)", isJobID: 32, isTab: 4, isCity: 9}
		],
		D5:[ 
			{isName: "Sneak Into The Gambling Den (1.92)", isJobID: 33, isTab: 5, isCity: 9},
			{isName: "Gamble Away All Your Savings (1.93)", isJobID: 34, isTab: 5, isCity: 9},
			{isName: "Bargain To Push 'Power Ups' To Pay Off Your Debts (1.891)", isJobID: 35, isTab: 5, isCity: 9},
			{isName: "Sell 'Power Ups' At School (2.087)", isJobID: 36, isTab: 5, isCity: 9},
			{isName: "Start An Operation (1.981)", isJobID: 37, isTab: 5, isCity: 9},
			{isName: "Pay Off Your Debts (1.988)", isJobID: 38, isTab: 5, isCity: 9},
			{isName: "Run Your Empire (2.241)", isJobID: 39, isTab: 5, isCity: 9},
			{isName: "Join The Inner Circle (2.087)", isJobID: 40, isTab: 5, isCity: 9}
		],
		D6:[
			{isName: "Analyze Your Agent's Data (1.93)", isJobID: 41, isTab: 6, isCity: 9},
			{isName: "Organize A Raid On The Gang Hideout (1.891)", isJobID: 42, isTab: 6, isCity: 9},
			{isName: "Ambush The Convoy Transporting The Gang Boss (2.087)", isJobID: 43, isTab: 6, isCity: 9},
			{isName: "Drive The Gang Boss To A Safehouse (2.045)", isJobID: 44, isTab: 6, isCity: 9},
			{isName: "Forge The Reports (2.176)", isJobID: 45, isTab: 6, isCity: 9},
			{isName: "Observe Your Agent Snooping Around (2.083)", isJobID: 46, isTab: 6, isCity: 9},
			{isName: "Snipe Your Agent Before He Goes Public (1.929)", isJobID: 47, isTab: 6, isCity: 9},
			{isName: "Close The Investigation (2.048)", isJobID: 48, isTab: 6, isCity: 9}
		],
		D7:[
			{isName: "Track Down Your Target (2.134)", isJobID: 49, isTab: 7, isCity: 9},
			{isName: "Assassinate Your Target (2.027)", isJobID: 50, isTab: 7, isCity: 9},
			{isName: "Declare Your Retirement To The Boss (2)", isJobID: 51, isTab: 7, isCity: 9},
			{isName: "Chase Down Your Son's Kidnappers (2.231)", isJobID: 52, isTab: 7, isCity: 9},
			{isName: "Sneak Into The Manor (2.19)", isJobID: 53, isTab: 7, isCity: 9},
			{isName: "Rescue Your Son (1.92)", isJobID: 54, isTab: 7, isCity: 9},
			{isName: "Take Out The Boss And His Guards (2.037)", isJobID: 55, isTab: 7, isCity: 9},
			{isName: "Retire To The Isle Of Wight (2.226)", isJobID: 56, isTab: 7, isCity: 9}
		],
		D8:[
			{isName: "Meet Your Source (2.021)", isJobID: 57, isTab: 8, isCity: 9},
			{isName: "Investigate The Trail Of The Puzzle Box (2.252)", isJobID: 58, isTab: 8, isCity: 9},
			{isName: "Audition Your Potential Partners (2.045)", isJobID: 59, isTab: 8, isCity: 9},
			{isName: "Storm The Tower Of London (2.037)", isJobID: 60, isTab: 8, isCity: 9},
			{isName: "Steal The Puzzle Box (2.134)", isJobID: 61, isTab: 8, isCity: 9},
			{isName: "Fight Off The Police (2.279)", isJobID: 62, isTab: 8, isCity: 9},
			{isName: "Escape Into The Back Alleys (2.133)", isJobID: 63, isTab: 8, isCity: 9},
			{isName: "Open The Puzzle Box (1.969)", isJobID: 64, isTab: 8, isCity: 9}
		],
		D9:[
			{isName: "Set Up A Drug Racket From Your Kebab Shop (2.193)", isJobID: 65, isTab: 9, isCity: 9},
			{isName: "Expand The Business With Turkish Smugglers' Help (2.19)", isJobID: 66, isTab: 9, isCity: 9},
			{isName: "Reap The Benefits (2.226)", isJobID: 67, isTab: 9, isCity: 9},
			{isName: "Suspect Foul Play (2.187)", isJobID: 68, isTab: 9, isCity: 9},
			{isName: "Silence Your Disloyal Associates (2.134)", isJobID: 69, isTab: 9, isCity: 9},
			{isName: "Pretend To Be A Survivor (2.134)", isJobID: 70, isTab: 9, isCity: 9},
			{isName: "Get Compensation From Insurance Company (2.048)", isJobID: 71, isTab: 9, isCity: 9},
			{isName: "Open Various Branches Across London But Beware (2.051)", isJobID: 72, isTab: 9, isCity: 9}
		],
		D10:[
			{isName: "Queue Up At The Grande Stadium For The Game (2.134)", isJobID: 73, isTab: 10, isCity: 9},
			{isName: "Enjoy The Game At Rival Team's Cost (2.252)", isJobID: 74, isTab: 10, isCity: 9},
			{isName: "Go To A Pub To Celebrate Your Team's Win (2.231)", isJobID: 75, isTab: 10, isCity: 9},
			{isName: "Poke Your Team's Victory In Rival Fans' Faces (2.226)", isJobID: 76, isTab: 10, isCity: 9},
			{isName: "Defend Yourself From The Rival's Fans (2.231)", isJobID: 77, isTab: 10, isCity: 9},
			{isName: "Make A Run For It And Hide (2.187)", isJobID: 78, isTab: 10, isCity: 9},
			{isName: "Speak To Your Uncle With Connections (2.222)", isJobID: 79, isTab: 10, isCity: 9},
			{isName: "Make The Club Pay For Their Disrespect (2.226)", isJobID: 80, isTab: 10, isCity: 9}
		]
	};
	
	var SAJobMap = {
		D1:[
			{isName: "Help Out At The Shipwreck (1.754)", isJobID: 1, isTab: 1, isCity: 10},
			{isName: "Steal The Cargo Of Diamonds (1.945)", isJobID: 2, isTab: 1, isCity: 10},
			{isName: "Hunt For The Highest Bidder (1.98)", isJobID: 3, isTab: 1, isCity: 10},
			{isName: "Rally The Union To Join Your Operation (1.994)", isJobID: 4, isTab: 1, isCity: 10},
			{isName: "Hide Your Shipment (2.024)", isJobID: 5, isTab: 1, isCity: 10},
			{isName: "Discover A Rat In Your Operation (2.024)", isJobID: 6, isTab: 1, isCity: 10},
			{isName: "Hire The Mafia As Muscle (2.047)", isJobID: 7, isTab: 1, isCity: 10},
			{isName: "Protect Your Shipment Into International Waters (2.126)", isJobID: 8, isTab: 1, isCity: 10},
			{isName: "Join Forces With The Mafia (2.126)", isJobID: 9, isTab: 1, isCity: 10},
			{isName: "Set Up A Diamond Smuggling Racket (2.237)", isJobID: 10, isTab: 1, isCity: 10}
		],
		D2:[
			{isName: "Steal A Diamond At Work (1.822)", isJobID: 11, isTab: 2, isCity: 10},
			{isName: "Defend Yourself Against The Supervisors (1.949)", isJobID: 12, isTab: 2, isCity: 10},
			{isName: "Distract The Guards (2.024)", isJobID: 13, isTab: 2, isCity: 10},
			{isName: "Loot The Safe Of Diamonds (1.889)", isJobID: 14, isTab: 2, isCity: 10},
			{isName: "Locate The Militia By The River (1.889)", isJobID: 15, isTab: 2, isCity: 10},
			{isName: "Trade Diamonds For High-Grade Weapons (2.105)", isJobID: 16, isTab: 2, isCity: 10},
			{isName: "Incite The Miners to Riot (2.126)", isJobID: 17, isTab: 2, isCity: 10},
			{isName: "Wage War Against The Mining Corporation (2.086)", isJobID: 18, isTab: 2, isCity: 10},
			{isName: "Establish Yourself As A Rebel Leader (2.19)", isJobID: 19, isTab: 2, isCity: 10},
			{isName: "Distribute The Spoils Of War (2.267)", isJobID: 20, isTab: 2, isCity: 10}
		],
		D3:[ 
			{isName: "Accept The Job For A Top-Secret Mission (1.889)", isJobID: 21, isTab: 3, isCity: 10},
			{isName: "Reach The Medical Facility Without Being Noticed (2.126)", isJobID: 22, isTab: 3, isCity: 10},
			{isName: "Dodge All High Security Elements (2.024)", isJobID: 23, isTab: 3, isCity: 10},
			{isName: "Gain Access To The Disease Containment Chamber (2.126)", isJobID: 24, isTab: 3, isCity: 10},
			{isName: "Eliminate An Unexpected Roadblock (2.024)", isJobID: 25, isTab: 3, isCity: 10},
			{isName: "Open The Virus Vault With Protective Gear (2.227)", isJobID: 26, isTab: 3, isCity: 10},
			{isName: "Take What You Came For (2.126)", isJobID: 27, isTab: 3, isCity: 10},
			{isName: "Flee The Scene Without Leaving A Trail (2.204)", isJobID: 28, isTab: 3, isCity: 10},
			{isName: "Be At The Right Place At The Right Time (2.18)", isJobID: 29, isTab: 3, isCity: 10},
			{isName: "Sell The Virus To The Highest Bidder (2.289)", isJobID: 30, isTab: 3, isCity: 10}
		],
		D4:[
			{isName: "Spy On The Witch Doctor (1.786)", isJobID: 31, isTab: 4, isCity: 10},
			{isName: "Discover The Secret Location Of The Herbs (1.877)", isJobID: 32, isTab: 4, isCity: 10},
			{isName: "Fake An Injury And Seek Doctor's Aid (1.913)", isJobID: 33, isTab: 4, isCity: 10},
			{isName: "Offer A Contract To The Witch Doctor (1.9)", isJobID: 34, isTab: 4, isCity: 10},
			{isName: "Threaten The Doctor To Part With His \"Herbal Meds\" (2.127)", isJobID: 35, isTab: 4, isCity: 10},
			{isName: "Gather A Mob To Force Doctor To Agree (1.99)", isJobID: 36, isTab: 4, isCity: 10},
			{isName: "Set Doctor's House On Fire As A Warning (2.225)", isJobID: 37, isTab: 4, isCity: 10},
			{isName: "Discover That The Doctor Has Escaped (2.162)", isJobID: 38, isTab: 4, isCity: 10},
			{isName: "Launch A Manhunt For Doctor (2.254)", isJobID: 39, isTab: 4, isCity: 10},
			{isName: "Ensure That The Doctor Is In The Boss' Clutches (2.294)", isJobID: 40, isTab: 4, isCity: 10}
		],
		D5:[ 
			{isName: "Acquire Car Parts From Local Hoodlums (1.798)", isJobID: 41, isTab: 5, isCity: 10},
			{isName: "Offer Your Expertise For Their Business (1.875)", isJobID: 42, isTab: 5, isCity: 10},
			{isName: "Go Through A Series Of Tests To Prove Yourself (1.913)", isJobID: 43, isTab: 5, isCity: 10},
			{isName: "Get Recruited For A Lucrative Project (2.139)", isJobID: 44, isTab: 5, isCity: 10},
			{isName: "Proceed To Dealer's Warehouse (1.965)", isJobID: 45, isTab: 5, isCity: 10},
			{isName: "Discover A Special Package In The Car (2.211)", isJobID: 46, isTab: 5, isCity: 10},
			{isName: "Notice That You Are Being Followed (2.246)", isJobID: 47, isTab: 5, isCity: 10},
			{isName: "Lose Them On The Highway (2.238)", isJobID: 48, isTab: 5, isCity: 10},
			{isName: "Bury Your Treasure In A Nearby Field (2.258)", isJobID: 49, isTab: 5, isCity: 10},
			{isName: "Finish Your Car-Jacking Job As Planned (2.302)", isJobID: 50, isTab: 5, isCity: 10}
		],
		D6:[
			{isName: "Assign Your Protege To An Undercover Operation (1.849)", isJobID: 51, isTab: 6, isCity: 10},
			{isName: "Crack Down On Narcotics Rings In The Slums (1.887)", isJobID: 52, isTab: 6, isCity: 10},
			{isName: "Bring Your Protege In On Your Operation (2.154)", isJobID: 53, isTab: 6, isCity: 10},
			{isName: "Stage A Break In Into The Evidence Room (1.951)", isJobID: 54, isTab: 6, isCity: 10},
			{isName: "Find Prospective Buyers In The Mafia (2.196)", isJobID: 55, isTab: 6, isCity: 10},
			{isName: "Resell Snow Candy To The Mafia (2.225)", isJobID: 56, isTab: 6, isCity: 10},
			{isName: "Run A Substance Raid In The Slums (2.24)", isJobID: 57, isTab: 6, isCity: 10},
			{isName: "Fake The Arrest Of Your Protege (2.239)", isJobID: 58, isTab: 6, isCity: 10},
			{isName: "Shift To Another Precinct In The City (2.267)", isJobID: 59, isTab: 6, isCity: 10},
			{isName: "Get Cure For Disease With Your Profits (2.306)", isJobID: 60, isTab: 6, isCity: 10}
		],
		D7:[
			{isName: "Refuse To Poach For Rhino Horns And Ivory (1.874)", isJobID: 61, isTab: 7, isCity: 10},
			{isName: "Give In To Militant Pressure To Poach (1.913)", isJobID: 62, isTab: 7, isCity: 10},
			{isName: "Track Down And Hunt Rhinos (2.154)", isJobID: 63, isTab: 7, isCity: 10},
			{isName: "Make A Futile Attempt To Escape Rangers (2.184)", isJobID: 64, isTab: 7, isCity: 10},
			{isName: "Endure Torture During Interrogation (2.211)", isJobID: 65, isTab: 7, isCity: 10},
			{isName: "Cut A Deal With Rangers (2.224)", isJobID: 66, isTab: 7, isCity: 10},
			{isName: "Lead Rangers To Closest Militant Hideout (2.232)", isJobID: 67, isTab: 7, isCity: 10},
			{isName: "Take Cover From Gunfire (2.246)", isJobID: 68, isTab: 7, isCity: 10},
			{isName: "Expose Other Militant Pockets (2.296)", isJobID: 69, isTab: 7, isCity: 10},
			{isName: "Become An Informer For The Rangers (2.313)", isJobID: 70, isTab: 7, isCity: 10}
		],
		D8:[
			{isName: "Launch An Assault On The Football Stadium (2.09)", isJobID: 71, isTab: 8, isCity: 10},
			{isName: "Demand That The President Be Surrendered To You (1.926)", isJobID: 72, isTab: 8, isCity: 10},
			{isName: "Give The President Time To Escape (2.267)", isJobID: 73, isTab: 8, isCity: 10},
			{isName: "Launch Deadly Virus Grenades Into The Crowd (2.196)", isJobID: 74, isTab: 8, isCity: 10},
			{isName: "Abduct The Nation's Most Influential Media Mogul (2.296)", isJobID: 75, isTab: 8, isCity: 10},
			{isName: "Blow Up The Grounded Blimp To Cover Your Escape (2.241)", isJobID: 76, isTab: 8, isCity: 10},
			{isName: "Secure The Hideout While You Wait For The Boss (2.311)", isJobID: 77, isTab: 8, isCity: 10},
			{isName: "Persuade The Mogul To Join Your Cause (2.282)", isJobID: 78, isTab: 8, isCity: 10},
			{isName: "Release Footage Of The President Abandoning The Stadium Victims (2.366)", isJobID: 79, isTab: 8, isCity: 10},
			{isName: "Influence Public Opinion Through The Mogul's News Networks (2.395)", isJobID: 80, isTab: 8, isCity: 10}
		],
		D9:[
			{isName: "Alert President Of Public Frenzy (1.964)", isJobID: 81, isTab: 9, isCity: 10},
			{isName: "Call For A Meeting In A Secluded Location (2.224)", isJobID: 82, isTab: 9, isCity: 10},
			{isName: "Join President's Entourage At Springbok (2.296)", isJobID: 83, isTab: 9, isCity: 10},
			{isName: "Protect President From Public Humiliation (2.239)", isJobID: 84, isTab: 9, isCity: 10},
			{isName: "Transport President To Safe House (2.254)", isJobID: 85, isTab: 9, isCity: 10},
			{isName: "Double-Cross the President (2.324)", isJobID: 86, isTab: 9, isCity: 10},
			{isName: "Force President To Confront His Past (2.26)", isJobID: 87, isTab: 9, isCity: 10},
			{isName: "Record President's Confession To Crimes Of Genocide (2.285)", isJobID: 88, isTab: 9, isCity: 10},
			{isName: "Tip-Off President's Whereabouts To Police (2.387)", isJobID: 89, isTab: 9, isCity: 10},
			{isName: "Escape Safe House Unnoticed (2.401)", isJobID: 90, isTab: 9, isCity: 10}
		],
		D10:[
			{isName: "Gain The Cooperation Of Key Members Of Parliament (2.163)", isJobID: 91, isTab: 10, isCity: 10},
			{isName: "Take Control Of The Leading Political Party (2.225)", isJobID: 92, isTab: 10, isCity: 10},
			{isName: "Organize Terror Attacks By Your Militants (2.296)", isJobID: 93, isTab: 10, isCity: 10},
			{isName: "Double Cross And Have Them Eliminated (2.222)", isJobID: 94, isTab: 10, isCity: 10},
			{isName: "Declare A State Of Emergency In The Country (2.253)", isJobID: 95, isTab: 10, isCity: 10},
			{isName: "Establish Martial Law (2.282)", isJobID: 96, isTab: 10, isCity: 10},
			{isName: "Offer Restitution To Terror Attack Victims (2.270)", isJobID: 97, isTab: 10, isCity: 10},
			{isName: "Publicize Your Philanthropy To Win Public Approval (2.290)", isJobID: 98, isTab: 10, isCity: 10},
			{isName: "Get Sworn In As President (2.416)", isJobID: 99, isTab: 10, isCity: 10},
			{isName: "Offer Your Associates Key Roles In The Cabinet (2.423)", isJobID: 120, isTab: 10, isCity: 10}
		]
	};	
	
	var MEXJobMap = {
		D1:[
			{isName: "Rob Rival Cartel's Latest Shipment (1.851)", isJobID: 1, isTab: 1, isCity: 11},
			{isName: "Escape Cartel's Retaliation (1.859)", isJobID: 2, isTab: 1, isCity: 11},
			{isName: "Visit Your Go-Down To Check On The Goods (2.039)", isJobID: 3, isTab: 1, isCity: 11},
			{isName: "Receive A Threat That Is Loud But Not So Clear (1.884)", isJobID: 4, isTab: 1, isCity: 11},
			{isName: "Extort Vital Information From Local Peddlers (1.942)", isJobID: 5, isTab: 1, isCity: 11},
			{isName: "Dispose Of Them Once You've Heard Enough (2.013)", isJobID: 6, isTab: 1, isCity: 11},
			{isName: "Declare War On Rival's Hacienda (1.993)", isJobID: 7, isTab: 1, isCity: 11},
			{isName: "Put An End To This Rivalry Once And For All (2.075)", isJobID: 8, isTab: 1, isCity: 11},
			{isName: "Retrieve All That Was Yours And More (2.076)", isJobID: 9, isTab: 1, isCity: 11},
			{isName: "Offer Cops Plata O Plomo To Run A Smooth Operation (2.124)", isJobID: 10, isTab: 1, isCity: 11}
		],
		D2:[
			{isName: "Reward Your Cartel Moles For Inside Information (2.089)", isJobID: 11, isTab: 2, isCity: 11},
			{isName: "Recruit Ex-Elite Commandos To Strengthen Your Mafia (2.105)", isJobID: 12, isTab: 2, isCity: 11},
			{isName: "Use Your Crew To Intimidate The Cartel's Thugs (2.236)", isJobID: 13, isTab: 2, isCity: 11},
			{isName: "Take Control Of Product Distribution On The Streets (2.144)", isJobID: 14, isTab: 2, isCity: 11},
			{isName: "Orchestrate A Jail Break To Keep The Federales Busy (2.080)", isJobID: 15, isTab: 2, isCity: 11},
			{isName: "Recruit The Convicts With The Most Useful Skills (2.080)", isJobID: 16, isTab: 2, isCity: 11},
			{isName: "Steal Military Surplus To Get Equipped For The Showdown (2.233)", isJobID: 17, isTab: 2, isCity: 11},
			{isName: "Use Superior Military Tactics To Take Down The Cartel (2.159)", isJobID: 18, isTab: 2, isCity: 11},
			{isName: "Establish Smooth Supply Through Monopolized Routes (2.232)", isJobID: 19, isTab: 2, isCity: 11},
			{isName: "Grow The Operation To Facilitate Trans-Atlantic Trafficking (2.255)", isJobID: 20, isTab: 2, isCity: 11}
		],
		D3:[ 
			{isName: "Escape Through The Desert With Fellow Immigrants (2.095)", isJobID: 21, isTab: 3, isCity: 11},
			{isName: "Fight Back When Coyotes Turn On You (2.119)", isJobID: 22, isTab: 3, isCity: 11},
			{isName: "Make Your Way Through The Desert To Safety (2.080)", isJobID: 23, isTab: 3, isCity: 11},
			{isName: "Stumble Upon A Cartel's Secret Goods Drop (2.208)", isJobID: 24, isTab: 3, isCity: 11},
			{isName: "Wait For Nightfall To Steal The Cartel's Money (2.101)", isJobID: 25, isTab: 3, isCity: 11},
			{isName: "Set Goods On Fire To Distract The Guards (2.233)", isJobID: 26, isTab: 3, isCity: 11},
			{isName: "Retrieve The Child From His Hiding Place (2.136)", isJobID: 27, isTab: 3, isCity: 11},
			{isName: "Kill To Protect The Only Family You Have Left (2.136)", isJobID: 28, isTab: 3, isCity: 11},
			{isName: "Stow Away On Goods Delivery Plane (2.280)", isJobID: 29, isTab: 3, isCity: 11},
			{isName: "Bribe The Pilot When You're Discovered (2.323)", isJobID: 30, isTab: 3, isCity: 11}
		],
		D4:[
			{isName: "Arrange The Sale Of Your New Weapons Shipment (2.069)", isJobID: 31, isTab: 4, isCity: 11},
			{isName: "Refuse To Deliver Until The Cobrizo Cartel Pays In Full (2.098)", isJobID: 32, isTab: 4, isCity: 11},
			{isName: "Accept Your Brother's Help To Transport The Shipment (2.118)", isJobID: 33, isTab: 4, isCity: 11},
			{isName: "Fend Off An Attack On The Way To The Weapons Cache (2.213)", isJobID: 34, isTab: 4, isCity: 11},
			{isName: "Give Up Your Hideout In Exchange For Your Life (2.163)", isJobID: 35, isTab: 4, isCity: 11},
			{isName: "Transport The Shipment To The Cobrizo Warehouse (2.232)", isJobID: 36, isTab: 4, isCity: 11},
			{isName: "Invite The Cobrizo Cartel To Inspect New Merchandise (2.111)", isJobID: 37, isTab: 4, isCity: 11},
			{isName: "Avoid The Cross-Fire As Interpol Makes Arrests (2.268)", isJobID: 38, isTab: 4, isCity: 11},
			{isName: "Track Down Your Brother At The Cobrizo Safe House (2.204)", isJobID: 39, isTab: 4, isCity: 11},
			{isName: "Make Peace With Your Decision To Get Revenge (2.301)", isJobID: 40, isTab: 4, isCity: 11}
		],
		D5:[ 
			{isName: "Abduct Passed Out Party Goers (2.097)", isJobID: 41, isTab: 5, isCity: 11},
			{isName: "Harvest Organs For Smuggling (2.126)", isJobID: 42, isTab: 5, isCity: 11},
			{isName: "Accompany Team On Lucrative Operation (2.217)", isJobID: 43, isTab: 5, isCity: 11},
			{isName: "Be Rescued By A Group Of Autodefensas (2.101)", isJobID: 44, isTab: 5, isCity: 11},
			{isName: "Refuse Doctor's Diagnosis Of Amnesia (2.059)", isJobID: 45, isTab: 5, isCity: 11},
			{isName: "Attempt To Unravel Your Identity (2.235)", isJobID: 46, isTab: 5, isCity: 11},
			{isName: "Reject Your Mafia's Proposal To Rejoin Family (2.114)", isJobID: 47, isTab: 5, isCity: 11},
			{isName: "Cut Off All Ties With Your Mafia (2.271)", isJobID: 48, isTab: 5, isCity: 11},
			{isName: "Embrace Autodefensas' Ideology As Your Own (2.173)", isJobID: 49, isTab: 5, isCity: 11},
			{isName: "Put An End To Your Ex-MafiaÃ¢â‚¬â„¢s Operations (2.317)", isJobID: 50, isTab: 5, isCity: 11}
		],
		D6:[ 
			{isName: "Lure The Casino Owner's Wife Away From The Party (2.113)", isJobID: 51, isTab: 6, isCity: 11},
			{isName: "Demand A Ransom From The Casino Owner (2.195)", isJobID: 52, isTab: 6, isCity: 11},
			{isName: "Hold Up Under Intense Interrogation (2.164)", isJobID: 53, isTab: 6, isCity: 11},
			{isName: "Have Your 'Lawyer' Plant The Call Jammer (2.245)", isJobID: 54, isTab: 6, isCity: 11},
			{isName: "Evade The Police At The Ransom Drop Site (2.195)", isJobID: 55, isTab: 6, isCity: 11},
			{isName: "Snatch The Casino Owner In The Confusion (2.249)", isJobID: 56, isTab: 6, isCity: 11},
			{isName: "Use The Owner To Get Past Casino Security (2.245)", isJobID: 57, isTab: 6, isCity: 11},
			{isName: "Empty The Vault Before The Guards Wise Up (2.258)", isJobID: 58, isTab: 6, isCity: 11},
			{isName: "Get Rid Of Excess Baggage (2.290)", isJobID: 59, isTab: 6, isCity: 11},
			{isName: "Lie Low Until The Excitement Dies Down (2.319)", isJobID: 60, isTab: 6, isCity: 11}
		],
		D7:[ 
			{isName: "Meet With A Don To Accept A Contract (2.204)", isJobID: 61, isCity: 11, isTab: 7},
			{isName: "Escape When You're Set Up For His Murder (2.257)", isJobID: 62, isCity: 11, isTab: 7},
			{isName: "Force Police Involvement By Faking a Tip (2.184)", isJobID: 63, isCity: 11, isTab: 7},
			{isName: "Equip Yourself At The Station's Armory (2.281)", isJobID: 64, isCity: 11, isTab: 7},
			{isName: "Storm The Warehouse To Rescue Your Comrades (2.225)", isJobID: 65, isCity: 11, isTab: 7},
			{isName: "Hide Evidence Of Their Criminal Double Life (2.282)", isJobID: 66, isCity: 11, isTab: 7},
			{isName: "Chase Down The Old Don's Lieutenant (2.230)", isJobID: 67, isCity: 11, isTab: 7},
			{isName: "Record His Confession To Killing The Don (2.294)", isJobID: 68, isCity: 11, isTab: 7},
			{isName: "Deliver The Lieutenant To The Don's Family (2.267)", isJobID: 69, isCity: 11, isTab: 7},
			{isName: "Split The Reward Between Your Comrades' Families (2.334)", isJobID: 70, isCity: 11, isTab: 7}
		],
		D8:[ 
			{isName: "Practice Free Climbing At An Old Temple (2.211)", isJobID: 71, isCity: 11, isTab: 8},
			{isName: "Stumble On Ancient Mayan Treasures (2.246)", isJobID: 72, isCity: 11, isTab: 8},
			{isName: "Have Your Applications For The Contest Rejected (2.235)", isJobID: 73, isCity: 11, isTab: 8},
			{isName: "Bribe An Organizer To Squeeze You Into The Contest (2.287)", isJobID: 74, isCity: 11, isTab: 8},
			{isName: "Give Into The Greedy Organizer's Demands For More (2.293)", isJobID: 75, isCity: 11, isTab: 8},
			{isName: "Hand Over The Treasure In Exchange For Your Lives (2.210)", isJobID: 76, isCity: 11, isTab: 8},
			{isName: "Escape While The Organizer Deals With Your Friends (2.267)", isJobID: 77, isCity: 11, isTab: 8},
			{isName: "Follow Your Treasure (2.253)", isJobID: 78, isCity: 11, isTab: 8},
			{isName: "Deduce The Organizer's New Hiding Place (2.303)", isJobID: 79, isCity: 11, isTab: 8},
			{isName: "Bide your Time Until You Can Exact Revenge (2.348)", isJobID: 80, isCity: 11, isTab: 8}
		],
		D9:[ 
			{isName: "Meet A Rich Mining Boss Regarding A Secret Op (2.246)", isJobID: 81, isCity: 11, isTab: 9},
			{isName: "Accept Job And Ask To Use His Boats As Payment (2.299)", isJobID: 82, isCity: 11, isTab: 9},
			{isName: "Cause 'Accidents' On The Rival's Mine (2.333)", isJobID: 83, isCity: 11, isTab: 9},
			{isName: "Discover That The Boss Has Gone Back On His Word (2.259)", isJobID: 84, isCity: 11, isTab: 9},
			{isName: "Seek Fair Share Of Profits Among Other Demands (2.342)", isJobID: 85, isCity: 11, isTab: 9},
			{isName: "Use Force To Take Over Both Mines (2.311)", isJobID: 86, isCity: 11, isTab: 9},
			{isName: "Conduct A Dry Run On Your Smuggling Operations (2.347)", isJobID: 87, isCity: 11, isTab: 9},
			{isName: "Move Out Your Large Shipment Secretly (2.271)", isJobID: 88, isCity: 11, isTab: 9},
			{isName: "Discover You've Become The Target Of The Mining Lords (2.355)", isJobID: 89, isCity: 11, isTab: 9},
			{isName: "Escape An Attempt On Your Life (2.376)", isJobID: 90, isCity: 11, isTab: 9}
		],		
		D10:[ 
			{isName: "Escape The Raid On Your Packaging Unit (2.320)", isJobID: 91, isCity: 11, isTab: 10},
			{isName: "Track Your Seized Goods To The Comisaria (2.346)", isJobID: 92, isCity: 11, isTab: 10},
			{isName: "Send Your Partner To Make A Deal With The Police (2.168)", isJobID: 93, isCity: 11, isTab: 10},
			{isName: "Hear Of His Incarceration When He Refuses To Betray You (2.362)", isJobID: 94, isCity: 11, isTab: 10},
			{isName: "Sabotage The Bull Pens To Create A Diversion (2.232)", isJobID: 95, isCity: 11, isTab: 10},
			{isName: "Separate The Attorney General From His Security Detail (2.323)", isJobID: 96, isCity: 11, isTab: 10},
			{isName: "Get Your Revenge On The Attorney General (2.394)", isJobID: 97, isCity: 11, isTab: 10},
			{isName: "Use His Death To Instigate Riots Across The city (2.277)", isJobID: 98, isCity: 11, isTab: 10},
			{isName: "Attack The Comisaria To Free Your Partner (2.324)", isJobID: 99, isCity: 11, isTab: 10},
			{isName: "Steal Back All Your Confiscated Goods (2.445)", isJobID: 100, isCity: 11, isTab: 10}
		],
		D11:[ 
			{isName: "Crash The Meeting Between Your Rival And His Customer (1.888)", isJobID: 101, isCity: 11, isTab: 11},
			{isName: "Steal The Data That Was Being Sold (2.045)", isJobID: 102, isCity: 11, isTab: 11},
			{isName: "Draw Your Rival Away So Your Team Can Escape (2.098)", isJobID: 103, isCity: 11, isTab: 11},
			{isName: "Destroy Your Truck When He Loses Your Trail (2.01)", isJobID: 104, isCity: 11, isTab: 11},
			{isName: "Survive The Perils Of The Desert At Night (2.103)", isJobID: 105, isCity: 11, isTab: 11},
			{isName: "Rendezvous With Your Team At A Secure Location (2.069)", isJobID: 106, isCity: 11, isTab: 11},
			{isName: "Hide In Plain Sight To Enter The Locked-Down Town (2.032)", isJobID: 107, isCity: 11, isTab: 11},
			{isName: "Send Out Feelers To Potential Buyers (2.045)", isJobID: 108, isCity: 11, isTab: 11},
			{isName: "Go On The Offensive And Track Down Your Rival (2.112)", isJobID: 109, isCity: 11, isTab: 11},
			{isName: "Eliminate The Threat Of His Retribution (2.16)", isJobID: 110, isCity: 11, isTab: 11}
		]
	};	
			
	var StamJobs = new Array(
		{isName: "Gain The Cooperation Of Key Members Of Parliament (2.163)", isJobID: 91, isCity: 10, isTab: 10},
		{isName: "Double Cross And Have Them Eliminated (2.222)", isJobID: 94, isCity: 10, isTab: 10},
		{isName: "Offer Restitution To Terror Attack Victims (2.270)", isJobID: 97, isCity: 10, isTab: 10},
		{isName: "Send Your Partner To Make A Deal With The Police (2.168)", isJobID: 93, isCity: 11, isTab: 10},
		{isName: "Sabotage The Bull Pens To Create A Diversion (2.232)", isJobID: 95, isCity: 11, isTab: 10},
		{isName: "Use His Death To Instigate Riots Across The city (2.277)", isJobID: 98, isCity: 11, isTab: 10}
	);
	
	var debug = false, userId = /sf_xw_user_id': '(.+)'/.exec(document.body.innerHTML)[1], refreshSigTimer = false, messageTimer, DroneLog = [], SecretDistrictCounter = 0, SDMap = new Array(), jobArray = new Array(), cash_in_hand, chkresources = false, SortLists = false, mexicoResourceError = 0, start_time = 0, ClickGo, JobMapCount = 0, isFirstLoad = true, SkillsTo, SkillToSpend = 'none', isSkillPointsAvaiable = parseInt($('#user_skill').text());

	/*Arena*/
	var logs=[], looted = {}, arenaRunning=false, closed=false, spinner = '<img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/mw_loader_final_v2.gif" width="32" height="32" />', mafia_attack = imgurl('icon_mafia_attack_22x16_01.gif','22','16','Mafia Attack Strength'), mafia_defense = imgurl('icon_mafia_defense_22x16_01.gif','22','16','Mafia Defense Strength'), starimg = '<img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/TeamVSTeam/result_star_filled.png" width="12" height="12" align="top" />', nostarimg = '<img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/TeamVSTeam/result_star_grey.png" width="12" height="12" align="top" />',	socke, currdata, cmdqueue=[], meid, meteam, tscore = {"1":0,"2":0}, poweratt = undefined, poweruplist = {}, playerinfo={}, playerids={}, starting_in, starting_in_counter, stam_on_start=-1, healed_in, healed_in_counter, itemdatabase={}, friendlist={}, worstitems, stats = { arenas:0,crests:0, xp:0, stamina:0, respect_start:0, respect:0, ranks:[0,0,0,0,0,0], stars:0, score:0}, powerup_status = {}, last_update = 0, conn_checker, healtimer=[0,0,0,0,0,0], replenish=0, da_game = [], protect = {}, powerup_command = { count:{},active:-1,target:undefined }, show_config = false, over_table = false, reconnect_retry = 0, arenalist=[], lobby_arenas=[], current_arena_was, last_crests = false, stopAFTR = false, zserver = /\/\/(.*)\.mafiawars/.exec(document.location.href)[1];	
	/**/
	var Zangano = {
		Version: '0.10',
		CurrentLevel:$('#user_level').text(),
		isRunning: true,
		JobMap: new Array(),
		Imgs:{ 
			FamilyIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/family_icon_19x19pixels.png',
			EnergyIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-energy.gif',
			StaminaIcon: 'http://mwfb.static.zynga.com/mwfb/graphics/icon_stamina_16x16_01.gif',
			ExpIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_experience_16x16_01.gif',
			RubyStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_ruby_01.gif',
			GoldStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_gold_01.gif',
			SilverStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_silver_01.gif',
			BronzeStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_bronze_01.gif',
			ChestKey: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif',
			CashIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_cash_16x16_01.gif',
			AttackIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-attack.gif',
			DefenseIcon: 'http://mwfb.static.zynga.com/mwfb/graphics/icon-defense.gif',
			HealthIcon: 'http://mwfb.static.zynga.com/mwfb/graphics/icon-health.gif',
			En2xp: '',
			Iced: '',
			Killed: '',
			Loading: ''
		},
		resourceInfo:{
			currentEnergy: 0,
			currentStamina: 0,
			currentExperience: 0,
			currentCombinedRatio: 0
		},
		jobInfo:{
			timesJobDone: 0,
			timesToDoJob: 0,
			SwitchRatio: 0,
			SwitchAmount: 0
		},
		banditInfo:{
			crewMembers: 0,
			banditsActive: false,
			backUpBanditTimer: 6,
			Bandit_type: 0,
			Bandit_elim: 0,
			Bandit_timer: 0,
			testBanditTimer: 0
		},
		userStats: {
			firstRun: true,
			start_group_atk: 0,
			start_group_def: 0,
			group_atk: 0,
			group_def: 0
		},
		Saving:{
			/*Job Speed Menu*/
			jobSpeedMenu: 0,
			jobSpeed: 500,
			/*Bandit Menu*/
			BanditXPCheck: 1,
			BanditCSHCheck: 1,
			BanditJOBCheck: 1,
			BanditElapsedTimerXP: 4,
			BanditElapsedTimerCash: 4,
			/*Banking*/
			bankAbove: 0,
			NoBank: true,
			BuyCityStore: true,
			/*Fighting*/
			Bursts: 4,
			healAbove: 30,
			FightCity: 1,
			/*Robbing*/
			RobCity: 1,
			/*Spending*/
			NoResourceMenu:1,
			RestartIn: 5,
			SkillSpendingMenu:0,
			BG: 3
		}
	};
	
	var powerups = {
		1:{name:"Stamina Refill",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_staminarefill_01.png"},
		2:{name:"Arena Health Refill",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_arenahealthrefill_01.png"},
		3:{name:"Meta Flair",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_quartflair_01.png"},
		4:{name:"Pain Killer",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_painkiller_01.png"},
		5:{name:"Kamikaze",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_suckerpunch_01.png"},
		6:{name:"Drained",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_drained_02.png"},
		7:{name:"Reflector",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_reflector_01.png"},
		//8:{name:"Freeze",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_freeze_01.png"}
		//9:{name:"Dual Strike",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_dualstrike_01.png"}
		10:{name:"Tri-Rage",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_tri-rage_01.png"},
		//11:{name:"Dominade",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_dominade_01.png"}
	};

	var difficulty = [
		'Easy',
		'Normal',
		'Hard'
	];

	var r_difficulty = {
		'Easy':0,
		'Normal':1,
		'Hard':2
	};	

	$('a[id^="travel_menu_secret_"]').each(function(){
		SecretDistrictCounter++;
		var isName = $(this).text().trim();
		var isLink = $(this).prop('onclick');
		var isTab = /tab=(\d+)/.exec(isLink)[1];
		var isCity = /destination=(\d+)/.exec(isLink)[1];
		var new_district = {isName:isName, isTab:isTab, isCity:isCity};
		SDMap.push(new_district);
	});	
	
	function create_div() {
		if(document.getElementById('gxDiv')) {
			document.getElementById('gxDiv').innerHTML = MainIndexOf;
		} else {
			var gxDiv=document.createElement("div");
			gxDiv.id = 'gxDiv';
			var content=document.getElementById('content_row');
			content.insertBefore(gxDiv, content.firstChild);
			document.getElementById('gxDiv').innerHTML = MainIndexOf;
		}
	}

	var Zangano_Stylez = '<style type="text/css">'+
		'.Zangano_Box {float: left;overflow-x: hidden;width: 522px;}'+
		'.Zangano_TabBox {height: 27px;overflow: hidden;}'+
		'.Zangano_Tab {float: left;}'+
		'.Zangano_TabActive {opacity: 1;}'+
		'.Zangano_TabInActive {opacity: 0.7;}'+
		'.Zangano_TabStart {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/black_tabs_left.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);float: left;height: 28px;width: 3px;}'+
		'.Zangano_TabMiddle {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/black_tabs_slice.png") repeat scroll 0 0 rgba(0, 0, 0, 0);color: #FFFFFF;float: left;font-size: 14px;height: 28px;padding-left: 5px;padding-right: 10px;padding-top: 5px;}'+
		'.Zangano_TabEnd {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/black_tabs_right.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);float: left;height: 28px;width: 3px;}'+
		'.Zangano_TabContent {background-color: #111111;border: 1px solid #666666;overflow: hidden;}'+
		'.Zangano_TabContentDiv {height: 230px;margin-left: 10px;overflow: auto;}'+
		'#ZX_Spart_loading { display:none; }'+
		'#ZX_Spart_table td { padding:3px; }'+
		'#ZX_Spart_table th { padding:3px; }'+
		'#ZX_Spart_table { width:100%; border: 1px solid black; }'+
		'#ZX_Spart_table tr:nth-child(odd) { background: #181818; }'+
		'.ZX_Spart_teamblue { background: #0E374B !important;}'+
		'.ZX_Spart_teamred { background: #331A1E !important;}'+
		'.ZX_Spart_usepowerup { cursor:pointer; }'+
		'.ZX_Spart_notusepowerup { cursor:default; }'+
		'.ZX_Spart_puclick { cursor:pointer; }'+
		'.ZX_Spart_punoclick { cursor:default; }'+
		'.ZX_Spart_pufull { opacity:1; }'+
		'.ZX_Spart_puhalf { opacity:0.6; }'+
		'.ZX_Spart_puoff { opacity:0.2; }'+
		'.ZX_Spart_puactive { border:1px solid white; }'+
		'.ZX_Spart_punormal { border:1px solid #101010; }'+
		'.ZX_Spart_conf { display:none; }'+
//		'#ZX_Spart_delay { display:none; }'+
		'.ZX_Spart_offsh {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/Effect_opponentOverlay.png") 0 50% no-repeat;background-position:-10px -5px;padding-left: 30px;}'+
		'.ZX_Spart_defsh {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/Effect_opponentOverlay.png") 0 50% no-repeat;background-position:-230px -110px;padding-left: 30px;}'+
		'.ZX_Spart_lootlog { display:none; }'+
		'.ZX_Spart_arenalog { display:none; }'+
		'</style>';
		
	var optable = 
		'<tr><th style="width: 55px; height:20px;">Rank<img height="16" width="16" src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif" id="ZX_Spart_lockrank" style="display:none;" /></th>'+
		'<th>Opponent</th><th>Info</th><th>Respect</th><th style="width:65px;">Health</th><th>Score</th><th>Stamina</th><th style="width:80px;">Shields</th><th>Intervene</th></tr>'+
		'<tr id="ZX_Spart_op0"><td style="height:38px;"><span id="ZX_Spart_rank0">#1</span></td><td><span id="ZX_Spart_name0">Opponent 0</span></td><td><span id="ZX_Spart_diff0" class="difficulty"></span></td><td><span id="ZX_Spart_respect0" class="respect">0</span></td><td><span class="health" id="ZX_Spart_health0">0</span></td><td><span id="ZX_Spart_score0">0</span></td><td><span id="ZX_Spart_stam0" class="stamina">?</span></td><td><span id="ZX_Spart_pu0"></span></td><td><span id="ZX_Spart_usepu0"></span></td></tr>'+
		'<tr id="ZX_Spart_op1"><td style="height:38px;"><span id="ZX_Spart_rank1">#2</span></td><td><span id="ZX_Spart_name1">Opponent 1</span></td><td><span id="ZX_Spart_diff1" class="difficulty"></span></td><td><span id="ZX_Spart_respect1" class="respect">0</span></td><td><span class="health" id="ZX_Spart_health1">0</span></td><td><span id="ZX_Spart_score1">0</span></td><td><span id="ZX_Spart_stam1" class="stamina">?</span><td><span id="ZX_Spart_pu1"></span></td><td><span id="ZX_Spart_usepu1"></span></td></tr>'+
		'<tr id="ZX_Spart_op2"><td style="height:38px;"><span id="ZX_Spart_rank2">#3</span></td><td><span id="ZX_Spart_name2">Opponent 2</span></td><td><span id="ZX_Spart_diff2" class="difficulty"></span></td><td><span id="ZX_Spart_respect2" class="respect">0</span></td><td><span class="health" id="ZX_Spart_health2">0</span></td><td><span id="ZX_Spart_score2">0</span></td><td><span id="ZX_Spart_stam2" class="stamina">?</span><td><span id="ZX_Spart_pu2"></span></td><td><span id="ZX_Spart_usepu2"></span></td></tr>'+
		'<tr id="ZX_Spart_op3"><td style="height:38px;"><span id="ZX_Spart_rank3">#4</span></td><td><span id="ZX_Spart_name3">Opponent 3</span></td><td><span id="ZX_Spart_diff3" class="difficulty"></span></td><td><span id="ZX_Spart_respect3" class="respect">0</span></td><td><span class="health" id="ZX_Spart_health3">0</span></td><td><span id="ZX_Spart_score3">0</span></td><td><span id="ZX_Spart_stam3" class="stamina">?</span><td><span id="ZX_Spart_pu3"></span></td><td><span id="ZX_Spart_usepu3"></span></td></tr>'+
		'<tr id="ZX_Spart_op4"><td style="height:38px;"><span id="ZX_Spart_rank4">#5</span></td><td><span id="ZX_Spart_name4">Opponent 4</span></td><td><span id="ZX_Spart_diff4" class="difficulty"></span></td><td><span id="ZX_Spart_respect4" class="respect">0</span></td><td><span class="health" id="ZX_Spart_health4">0</span></td><td><span id="ZX_Spart_score4">0</span></td><td><span id="ZX_Spart_stam4" class="stamina">?</span><td><span id="ZX_Spart_pu4"></span></td><td><span id="ZX_Spart_usepu4"></span></td></tr>'+
		'<tr id="ZX_Spart_op5"><td style="height:38px;"><span id="ZX_Spart_rank5">#6</span></td><td><span id="ZX_Spart_name5">Opponent 5</span></td><td><span id="ZX_Spart_diff5" class="difficulty"></span></td><td><span id="ZX_Spart_respect5" class="respect">0</span></td><td><span class="health" id="ZX_Spart_health5">0</span></td><td><span id="ZX_Spart_score5">0</span></td><td><span id="ZX_Spart_stam5" class="stamina">?</span><td><span id="ZX_Spart_pu5"></span></td><td><span id="ZX_Spart_usepu5"></span></td></tr>';		

	var ChangeLogInfoz = 'Change Log: <br><br>' +
		'<span class="good">[v0.10]</span> &nbsp; <span class="more_in">[07 January 2015]</span><br> - Patch made for Mexico Secret district, buttons would magically not register and disappeared from screen causing script to screw itself up. CSS edits for massive Energy/experience amounts<br><br>'+
		'<span class="good">[v0.09]</span> &nbsp; <span class="more_in">[November-December 2014]</span><br> - Drunk and no memory of what was added on which dates.. <br><br>'+
		'<span class="good">[v0.08]</span> &nbsp; <span class="more_in">[14 November 2014]</span><br> - Spartacus added, so let dem bugs begin! <br><br>'+
		'<span class="good">[v0.07]</span> &nbsp; <span class="more_in">[27 October 2014]</span><br> - Added in 5 minute wait for Kamis, so XP wont disappear, fixed a few bugs that people had reported. <br><br>'+
		'<span class="good">[v0.06]</span> &nbsp; <span class="more_in">[22 October 2014]</span><br> - Released to all, with fighting added. <br> - with help from <a target="_blank" href="https://www.facebook.com/officerjakewebdesign">Officerjake - Web Design</a> i got a lot more css sorted out. <br><br>'+		
		'<span class="good">[v0.05]</span> &nbsp; <span class="more_in">[16 October 2014]</span><br> - Released to all, with no fighting added. <br> - Lots more jobbing fixes. <br><br>'+		
		'<span class="good">[v0.05]</span> &nbsp; <span class="more_in">[15 October 2014]</span><br> - Topmafia bonus added with other counters. <br><br>'+				
		'<span class="good">[v0.04]</span> &nbsp; <span class="more_in">[5 October 2014]</span><br> - More Jobbing fixes. <br><br>'+	
		'<span class="good">[v0.03]</span> &nbsp; <span class="more_in">[1 October 2014]</span><br> - Mexico Fight Jobs added in. <br> - Mexico District 9 & 10 ratios updated. <br><br>'+	
		'<span class="good">[v0.02]</span> &nbsp; <span class="more_in">[25 September 2014]</span><br> - Robbing added. <br> - Added in dragable jobs and fixed being able to select text afterwards. <br> - Added in spending/restart menu. <br><br>'+	
		'<span class="good">[v0.01]</span> &nbsp; <span class="more_in">[24 September 2014]</span><br> - Got Jobbing nearly all sorted <br> - Added in Recommended Job Highlighting. <br><br>'+
		'<span class="good">[v0.01]</span> &nbsp; <span class="more_in">[21 September 2014]</span><br> - started again... <br><br>';
/*start going thru*/
	var MainIndexOf = '<div style="padding-bottom:20px;" class="empire_main_module"><div id="BGS" style="background-color: #000000;border: 1px solid #666666;border-radius: 3px 3px 3px 3px;color: #FFFFFF; width: 735px; height: auto; background: background-size: 100%;">'+
		'<div style="background: url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/header_module_gradient.gif) repeat-x scroll 0 0 ;color: #FFCF01; font-size: 17px;font-weight: bold;height: 22px;width:725px; padding-left: 10px;padding-top: 10px;text-transform: uppercase;">Zangano.&#12324; v'+Zangano.Version+' <span style="float:right"><img title="Tattas Awareness Month" style="padding-right: 10px;margin-top:-2px;width:12px;height:18px" src=""> <a style="padding-right: 10px;margin-top:-14px;display:none;" class="sexy_button_new short orange" id="DxAS"><span><span> Autostarting... (stop) </span></span></a><a style="padding-right: 10px;margin-top:-14px;" class="sexy_button_new short green" id="start"><span><span>GO!</span></span></a><a href="#" style="padding-right: 10px;margin-top:-14px;display:none;" class="sexy_button_new short red" id="stop"><span><span>Stop</span></span></a><a href="#" style="padding-right: 10px;margin-top:-14px;" class="sexy_button_new short orange" id="close"><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/iced.png"></span></span></a></span></div>'+
		Zangano_Stylez+
		'<div style="width: 720px; padding: 0 7px; float: none; " class="Zangano_Box"> '+
			'<div style="height: 35px; border-bottom: 1px solid #333;" class="Zangano_TabBox">	'+
				'<div onclick="LoadZanganoMain();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="Zangano_Tab Zangano_TabActive" id="Zangano_MainTab">'+
					'<div class="Zangano_TabStart">&nbsp;</div>'+
					'<div class="Zangano_TabMiddle">Main</div>'+
					'<div class="Zangano_TabEnd">&nbsp;</div>'+
				'</div>'+
				'<div onclick="LoadZanganoConfig();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="Zangano_Tab Zangano_TabInActive" id="Zangano_ConfigTab">'+
					'<div class="Zangano_TabStart">&nbsp;</div>'+
					'<div class="Zangano_TabMiddle">Config</div>'+
					'<div class="Zangano_TabEnd">&nbsp;</div>'+
				'</div>'+
				'<div onclick="LoadZanganoJobSetup();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="Zangano_Tab Zangano_TabInActive" id="Zangano_JobSetupTab">'+
					'<div class="Zangano_TabStart">&nbsp;</div>'+
					'<div class="Zangano_TabMiddle">Job Selection</div>'+
					'<div class="Zangano_TabEnd">&nbsp;</div>'+
				'</div>'+
				'<div onclick="LoadZanganoJobList();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="Zangano_Tab Zangano_TabInActive" id="Zangano_JobListTab">'+
					'<div class="Zangano_TabStart">&nbsp;</div>'+
					'<div class="Zangano_TabMiddle">Job List</div>'+
					'<div class="Zangano_TabEnd">&nbsp;</div>'+
				'</div>'+
				'<div onclick="LoadZanganoLootLog();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="Zangano_Tab Zangano_TabInActive" id="Zangano_AllLootLog">'+
					'<div class="Zangano_TabStart">&nbsp;</div>'+
					'<div class="Zangano_TabMiddle">Log</div>'+
					'<div class="Zangano_TabEnd">&nbsp;</div>'+
				'</div>'+
				'<div onclick="LoadZanganoChangeLog();" style="float:right; cursor: pointer; padding-top: 8px" class="Zangano_Tab Zangano_TabInActive" id="Zangano_ChangeLogTab">'+
					'<div class="Zangano_TabStart">&nbsp;</div>'+
					'<div class="Zangano_TabMiddle">Change Log</div>'+
					'<div class="Zangano_TabEnd">&nbsp;</div>'+
				'</div>'+						
			'</div>'+
			'<div style="background-color: transparent; border: none;" class="Zangano_TabContent">'+
				'<div style="overflow: auto; height: auto; min-height:241px; margin-right: 0px; overflow-x: hidden;" class="Zangano_TabContentDiv">'+
					'<div id="Zangano_Main">'+
						'<span style="text-align:left; float: left; min-width: 100px;">&nbsp;In Action : <span id="inAction"><font color="gold">n/a</font></span></span><br>'+
						'<span style="text-align:right; float: right; min-width: 100px;">Ratios&nbsp;:<img width="12" height="12" src="' + Zangano.Imgs.EnergyIcon + '"><span id="energy_ratio_reqd">0</span>&nbsp;&nbsp;<img width="12" height="12" src="' + Zangano.Imgs.StaminaIcon + '"><span id="stamina_ratio_reqd">0</span>&nbsp;&nbsp;<img src="' + Zangano.Imgs.En2xp + '"><span id="combined_ratio_reqd">0</span></span><br style="line-height: 20px;">'+
						'<span style="text-align:right; float: right; min-width: 100px;"><span class="group_attack" title="Current Mafia Attack score" id="DX_atk_ttl">n/a</span>&nbsp;<span title="Mafia attack score gained this session" class="good" id="DX_atk_inc">+0</span>&nbsp;<span class="group_defense" title="Current Mafia Defense score" id="DX_def_ttl">n/a</span>&nbsp;<span title="Mafia defense score gained this session" class="good" id="DX_def_inc">+0</span></span><br style="line-height: 20px;">'+ 
						'<span style="text-align:right; float: right; min-width: 100px;"><img src="' + Zangano.Imgs.ExpIcon + '"> x<span id="master">0</span>&nbsp;<img src="' + Zangano.Imgs.EnergyIcon + '"> x<span id="wheel">0</span>&nbsp;<img src="' + Zangano.Imgs.CashIcon + '"> x<span id="bag">0</span></span><br style="line-height: 20px;">'+						
						'<span style="text-align:right; float: right; min-width: 100px;"><img src="' + Zangano.Imgs.Iced + '" title="Iced">&nbsp;:&nbsp;<span id="ZX_iced">0</span>&nbsp;&nbsp;<img src="' + Zangano.Imgs.Killed + '" title="Killed">&nbsp;:&nbsp;<span id="ZX_killed">0</span></span><br style="line-height: 20px;">'+
						'<span style="text-align:right; float: right; min-width: 100px;">Levelups: <span class="energy_highlight" id="Levelup">0</span></span><br>'+
						'<span style="text-align:left; float: left; width: 100%;">&nbsp;Status : <span id="status"></span></span><br>'+
						//'<tr><td>Connection:</td><td><span id="arena_connstatus">-</span> <span id="arena_connstatus2"></span></td></tr>'+ <span id="status">Not started</span>
						'<span id="doTheSpartDiv" style="display:none">'+
						'<table style="width:100%">'+
							'<tr><td style="width:185px">Connection: <span id="ZX_Spart_connstatus">-</span> <span id="ZX_Spart_connstatus2"></span> <span id="ZX_Spart_delay"></span></td><td>Crests: <span class="arena_mastery_crests" id="ZX_Spart_crests">Loading...</span></td></tr>'+
						'</table>'+
						'<table style="width:100%">'+
							'<tr><td valign="top">Time left:</td><td><span id="ZX_Spart_timeleftbar"></span></td></tr>'+
						'</table>'+
						'<table style="width:100%">'+
							'<tr><td valign="top">Power-Ups<br /><span class="more_in">(Click to use)</span>:</td><td valign="top"><span id="ZX_Spart_powerups"></span></td></tr>'+
						'</table>'+
						'<table style="width:100%">'+
							'<tr><td style="width:85px">Stamina:</td><td><span class="stamina" id="ZX_Spart_me_st">0</span>, next +<span id="ZX_Spart_replenish">?</span> in <span id="ZX_Spart_me_sr">0</span>s, used: <span class="stamina" id="ZX_Spart_me_stused">0</span></td></tr>'+
						'</table>'+
						'<table style="width:100%">'+
							'<tr><td style="width:85px">Health:</td><td><span class="health" id="ZX_Spart_me_health">100</span>% &nbsp; <span id="ZX_Spart_healin"></span></td></tr>'+
						'</table>'+
						'<table style="width:100%">'+
							'<tr><td style="width:88px">Teamscores:</td><td><span id="ZX_Spart_teamscore"></span></td></tr>'+
						'</table>'+
							'<table id="ZX_Spart_table" cellspacing=0>'+
							optable+
							'</table>'+
//						'<tr><td colspan="3">'+
//						'</td></tr>'+
						'</span>'+
						'<span style="text-align:left; float: left; width: 100%;">&nbsp;Last Levelup : <span id="LastLevelup"><font color="gold">n/a</font></span></span><br>'+
						'<span style="text-align:left; float: left; width: 100%;">&nbsp;Job List : <span id="JobList" class="energy_highlight">n/a</span></span><br>'+
					'</div>'+
				
					'<div style="display: none;" id="Zangano_Config">'+
						'<h3 style="text-align:center;">Zangano.&#12324; Config</h3>'+
						'<fieldset><legend><select id="DX_Opts"><option value="0">Job/Bandit Options</option><option value="1">Banking Options</option><option value="2">Fight Options</option><option value="3">Spending/Restart</option><option value="4">Arena Options</option><option value="5">Auto Posting</option><option value="6">Misc</option></select></legend>' + 
						
						'<div id="DX_Job_Opts">'+
						'Job Speed&nbsp;<select id="ZX_jobSpeed" onChange="jobSpeedSelector(this.value)"><option value="0">Quick</option><option value="1">Fast</option><option value="2">Medium</option><option value="3">Slow</option></select>'+
						'<br style="line-height: 30px;">'+
						'XP Bandit <select id="XPBanO" onChange="BanditXPCheck(this.selectedIndex)"><option value="0">Kill When Detected!</option><option value="1">Kill with 1 minute to go</option><option value="2">Kill with 2 minutes to go</option><option value="3">Kill with 3 minutes to go</option></select>'+
						'<br style="line-height: 30px;">'+
						'Cash Bandit <select id="CSHBanO" onChange="BanditCSHCheck(this.selectedIndex)"><option value="0">Kill When Detected!</option><option value="1">Keep Jobbing Thru it</option><option value="2">Kill with 1 minute to go</option><option value="3">Kill with 2 minutes to go</option><option value="4">Kill with 3 minutes to go</option></select>'+
						'<br style="line-height: 30px;">'+
						'Job Bandit <select id="JOBBanO" onChange="BanditJOBCheck(this.selectedIndex)"><option value="0">Kill When Detected!</option><option value="1">Wait it out!</option></select>'+
						'<br style="line-height: 30px;">'+
						'Stop if Mexico Boss is Active?&nbsp;<input type="checkbox" id="ZX_mexBossActive"/>'+
						'</div>'+ 
						//MUST ADD/TODO ^^
						
						'<div id="DX_Bank_Opts">'+
						'AutoBank Above: <input id="ZX_bankAbove" type="text" value="'+Zangano.Saving.bankAbove+'" style="width:50px;" />'+
						'<br style="line-height: 30px;">'+
						'Disable Banking in NY&nbsp;<input type="checkbox" id="ZX_disableNY"/>'+
						'<br style="line-height: 30px;">'+
						'Buy city store items in South Africa & Mexico <input type="checkbox" id="ZX_buyCityStore"/>'+
						'</div>'+
						
						'<div id="DX_Fight_Opts">'+
							'Heal City: <select id="ZX_healCity"><option value="1">New York</option><option value="7">Brazil</option><option value="8">Chicago</option><option value="9">London</option><option value="10">South Africa</option><option value="11">Mexico</option></select> when health is above : <input id="ZX_healAbove" type="text" value="'+Zangano.Saving.healAbove+'" style="width:35px;" /> '+	//'+parseInt((User.max_health*0.1)+20)+'
							'<br style="line-height: 30px;">'+
							'Use blacklist: <input id="ZX_blacklist" style="width:20px;" type="checkbox" checked /><span class="more_in">Save stronger opponents for session duration. To avoid fighting them again.</span>'+
							'<br style="line-height: 30px;">'+
							'Red ice: <input id="ZX_redice" style="width:20px;" type="checkbox" /><span class="more_in">Keep attacking, even if we lose.</span>'+
							'<br style="line-height: 30px;">'+
							'Power Attack:<input id="ZX_power" title="Use power attack" style="width:20px;" type="checkbox" checked />'+
							'<br style="line-height: 30px;">'+
							'Bursts: <input id="ZX_burst" title="Zynga multi-click, 1-4 valid. In case of revolvers, lower the value" type="text" value="4" maxlength="1" style="width:15px;"/>'+ //'Bursts: <input id="DX_FO_Bursts" type="text" value="'+Zangano.Saving.Bursts+'" style="width:15px;" />'+
							'<br style="line-height: 30px;">'+
							'<table>'+
								'<tr>'+
									'<td valign="top" style="border-top:1px dotted #999;">Character name filter:<br /></td>'+
									'<td><textarea id="ZX_namefilter" rows="3" cols="40"></textarea><br />Separate characters with space or new line.</td>'+
								'</tr>'+
								'<tr>'+
									'<td valign="top" style="border-top:1px dotted #999;">Family ID filter:<br /><a href="#" id="ZX_addfamily">Add link</a></td>'+
									'<td><textarea id="ZX_familyfilter" rows="4" cols="50"></textarea><br />Numbers only, separate with space or new line.</td>'+
								'</tr>'+
							'</table>'+
						'<b>KAMI</b>'+ 
						'<hr>'+
						'Recheck Target every: <input id="DX_FO_RCT" type="text" value="5" style="width:15px;" /> Seconds...<span class="more_in"> (Minimum: 5 seconds)</span>'+
						'<br style="line-height: 30px;">'+
						'Pause for 5 mins after an attack burst <input type="checkbox" id="ZX_FO_P5"/> <span class="more_in"> Work around for Zynga withholding XP </span>'+
						'</div>'+

						'<div id="DX_Spending_Opts">'+
						'When out of resources: <select id="ZX_noResources"><option value="0">Idle in:</option><option value="1">Restart</option><option value="2">Do Nothing!</option></select> <span style="display:none" id="ZX_idleCitySpan"><select id="ZX_idleCity"><option value="1">New York</option><option value="7">Brazil</option><option value="8">Chicago</option><option value="9">London</option><option value="10">South Africa</option><option value="11">Mexico</option></select></span>'+
						'<span style="display:none" id="ZX_restartSpan">'+
						' In: <input id="ZX_restartTime" type="text" value="'+Zangano.Saving.RestartIn+'" maxlength="4" style="width:15px;"/> Minute(s). <span class="more_in">(Minimum: 1)</span></span>'+
						'<br style="line-height: 30px;">'+
						'Apply <select id="ZX_skillSpending" onChange="SkillSpending(this.value)"><option value="0">No!</option><option value="1">Attack</option><option value="2">Defense</option><option value="3">Health</option><option value="4">Energy</option><option value="5">Stamina</option></select> Skillpoints <span style="display:none" id="ZX_spendSkillsWhen"><select id="ZX_spendSkills"><option value="0">when out of resources</option><option value="1">every levelup</option></select></span>'+
						'</div>'+
						
						'<div id="DX_Arena_Opts">'+
						'Join:&nbsp;<select id="ZX_Spart_arenatype" title="Select what Arena to join">'+(User.max_stamina<3000?'<option value="sw">20 Stamina</option>':'')+'<option value="lw">100 Stamina</option>'+(User.max_stamina>=3000?'<option value="hw">500 Stamina</option>':'')+'</select>&nbsp; <label><input type="checkbox" id="ZX_Spart_mobfury" title="Do 100/500 Mob-Fury Arenas instead of regular." />Mob-Fury Arenas <span class="more_in">(only 100 or 500 stamina)</span></label><br />'+
						'<span id="Arena_Switch_O"><input type="checkbox" id="arena_switch"/>&nbsp;Switch 500 Arenas to 100 Arenas When Below <input type="text" value="1000" id="arena_switch_v" style="width:30px;"> Stamina</br></span>'+
					//	'<label title="Rejoin arenas when done">Rejoin arenas <input type="checkbox" id="ZX_Spart_restart" /></label><br /> '+
					//	'<label>Retry when out of stamina <input type="checkbox" id="ZX_Spart_restart_stam" title="Restart after x minutes" /><span id="ZX_Spart_show_restart_stam"> after <input type="text" id="ZX_Spart_restart_minutes" value="5" title="Minutes before retrying to join" /> minutes.</label></span>'+
						'<label title="Use Powerattack" >Powerattack: <input type="checkbox" id="ZX_Spart_powerattack" checked /></label> &nbsp;Number of attacks: <input type="text" id="ZX_Spart_numatt" value="3" title="Number of attacks to batch, maximum=3" style="width:10px;"/><br>'+
						'Target to attack:<select id="ZX_Spart_seltarget" title="Decide target priority">'+
						'	<option value="lowhealth">Lowest health alive</option>'+
						'	<option value="highhealth">Highest health</option>'+
						'	<option value="mostpoints">Most points alive</option>'+
						'	<option value="leastpoints">Least points alive</option>'+
						'	<option value="mostrespect">Most respect alive</option>'+
						'	<option value="leastrespect">Least respect alive</option>'+
						'	<option value="allalive">Attack all alive</option>'+
						'	<option value="leastdiff" selected>Least difficulty</option>'+
						'</select><br />'+
		'<label>Don\'t attack defense shielded players: <input type="checkbox" id="ZX_Spart_skipshield" checked title="Skip def shielded players" /></label><br />'+
		'<label>Don\'t attack attack shielded players: <input type="checkbox" id="ZX_Spart_skipshield_a" title="Skip att shielded players" /></label><br />'+
		'<label title="Try to use Kamikazi boost before arena ends">Use kamikazi at the last <input type="text" value="20" id="ZX_Spart_boostkami_s" style="width:16px;">s of the battle: <input type="checkbox" id="ZX_Spart_boostkami" /></label><br />'+
		'Stop attacking: <select id="ZX_Spart_stopon" title="In-arena play style">'+
		'<option value="never" selected>never (attack until stamina is gone)</option>'+
		'<option value="stop">now (do not attack)</option>'+
		'<option value="teamleading">when your team is leading by x points (only MobFury)</option>'+
		'<option value="leading">when having the lead by a specific number of points</option>'+
		'<option value="leading3">when having the 3rd place by a specific number of points</option>'+
		'<option value="leading5">when having the 5th place by a specific number of points</option>'+
		'<option value="staminaused">when specific amount of stamina used</option>'+
		'<option value="staminaleft">when specific amount of stamina left</option>'+
		'<option value="score">when score reached. Not 100% accurate!</option>'+
		'<option value="stars">when specific stars archieved (only MobFury)</option>'+
		'</select><span id="ZX_Spart_show_stopon_value"> value: <input type="text" id="ZX_Spart_stoponvalue" value="0" style="width: 40px;" /></span><br />'+
		'<label title="Sort player list by rank">Do not sort player list: <input type="checkbox" id="ZX_Spart_sortplayer" /></label>'+
						
						/*							'Join:  Arenas. <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Switch 500 Arenas to 100 Arenas When Below Stamina <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Mob-Fury Arenas (only 100 or 500 stamina) <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Powerattack:  Number of attacks:  <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Target to attack:  <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Don\'t attack defense shielded players: <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Don\'t attack attack shielded players: <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Use kamikazi at the last s of the battle: <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Stop attacking:  <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Do not sort player list:  <span class="more_in">(Not Yet Added)</span>'+*/
						'</div>'+
						
						'<div id="DX_APost_Opts">'+
						'<input type="checkbox" id=""/> Autopost for crew  <span style="display:none">When under <input id="" type="text" value="18" maxlength="4" style="width:15px;"/></span> <span class="more_in">(Not Yet Added)</span>'+
						'<br style="line-height: 30px;">'+
						'Post Level up bonus: <span class="more_in">(Not Yet Added)</span> '+
						'<br style="line-height: 30px;">'+
						'Post bonuses with: <span class="more_in">(Not Yet Added)</span> '+
						'<br style="line-height: 30px;">'+
						'Remove post on next level up. <span class="more_in">(Not Yet Added)</span>'+
						'<br style="line-height: 30px;">'+
						'Your level up bonus tinyurl: <span class="more_in">(Not Yet Added)</span> '+
						'<br style="line-height: 30px;">'+
						'*To get a shorter link if you post your level up as a comment. IE tinyurl <span class="more_in">(Not Yet Added)</span>'+
						'<br style="line-height: 30px;">'+
						'Pause on bonuses with: <span class="more_in">(Not Yet Added)</span> '+
						'<br style="line-height: 30px;">'+
						'Pause on level <span class="more_in">(Not Yet Added)</span>'+
						'<br style="line-height: 30px;">'+
						'<span class="more_in">Autoposting can cause issues on some accounts. Disable if you experience them</span>'+
						'</div>'+

						'<div id="DX_Misc_Opts">'+
							'Collect Levelup Bonus <input type="checkbox" id=""/> <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Use Family XP to Level? <input type="checkbox" id=""/> <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Stop at level <input id="" type="text" value="0" maxlength="6" style="width:45px;"/> <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Heal when possible? (In NY) <input type="checkbox" id=""/> <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Autostart <input type="checkbox" id=""/> (Autoruns when MW starts, will only work if you have GM version installed) <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Debug For Sim is: Disabled <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Adding Seconds Into Timestamp: <input type="checkbox" id=""/> <span class="more_in">(Not Yet Added)</span>'+
							'<br style="line-height: 30px;">'+
							'Background <select id="BGC" onChange="BGCheck(this.selectedIndex)"><option value="0">Mexico</option><option value="1">London</option><option value="2">Hydro</option><option value="3">OfficerJAKE Special</option><option value="4">OfficerJAKE Halloween Special</option><option value="5">Plain Black (No Background)	</option></select>'+
						'</div>'+
						
						'</fieldset>'+
					'</div>'+
					
					'<div style="display: none;" id="Zangano_JobSetup">'+
						'<center><a id="Show_Opt_Energy" class="sexy_button_new green short"><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-energy.gif"> Energy</span></span></a>&nbsp;<a id="Show_Opt_Stamina" class="sexy_button_new short red"><span><span><img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_stamina_16x16_01.gif"> Stamina</span></span></a></center>'+
						'<span id="Energy_Opt" style="display:none">'+
						'<center>'+
						'Add the jobs you wish to perform...<br>'+
						'<a id="Show_Location_NY" class="sexy_button_new black short"><span><span>New York</span></span></a>&nbsp;'+
						'<a id="Show_Location_BRL" class="sexy_button_new black short"><span><span>Brazil</span></span></a>&nbsp;'+
						'<a id="Show_Location_CHI" class="sexy_button_new black short"><span><span>Chicago</span></span></a>&nbsp;'+
						'<a id="Show_Location_LON" class="sexy_button_new black short"><span><span>London</span></span></a>&nbsp;'+
						'<a id="Show_Location_SA" class="sexy_button_new black short"><span><span>South Africa</span></span></a>&nbsp;'+
						'<a id="Show_Location_MEX" class="sexy_button_new black short"><span><span>Mexico</span></span></a>&nbsp;'+
						'<a class="sexy_button_new black short orange" id="Show_Location_LT"><span><span>Limited Time</span></span></a>'+
						'</center>'+
					'<br>'+
					'<div id="Location_NY" style="display:none">'+
					'<center>';
					for(i = 1; i < Object.keys(NYJobMap).length+1; i++){
						MainIndexOf += ' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_'+(i+1)+'">D'+(i+1)+'</span></span></a> '
					}
					MainIndexOf += '</center>';
					for(i = 0; i < Object.keys(NYJobMap).length; i++){
						MainIndexOf += '<div id="NY_'+(i+2)+'" style="display:none">';
						for (ii = 0; ii < NYJobMap[Object.keys(NYJobMap)[i]].length; ii++) {
							MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:570px;float:left;"><div style="margin-top:5px;">' + NYJobMap[Object.keys(NYJobMap)[i]][ii].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_'+(i+2)+'_' + ii + '">Add</span></span></a></span></div></span></li>'
						}
						MainIndexOf += '</div>';
					}
					MainIndexOf += '</div>'+//end ny
					'<div id="Location_BRL" style="display:none">'+
					'<center>';
					for(i = 1; i < Object.keys(BRLJobMap).length+1; i++){
						MainIndexOf += ' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_'+i+'">D'+i+'</span></span></a> '
					}
					MainIndexOf += '</center>';
					for(i = 0; i < Object.keys(BRLJobMap).length; i++){
						MainIndexOf += '<div id="BRL_'+(i+1)+'" style="display:none">';
						for (ii = 0; ii < BRLJobMap[Object.keys(BRLJobMap)[i]].length; ii++) {
							MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:570px;float:left;"><div style="margin-top:5px;">' + BRLJobMap[Object.keys(BRLJobMap)[i]][ii].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_'+(i+1)+'_' + ii + '">Add</span></span></a></span></div></span></li>'
						}
						MainIndexOf += '</div>';
					}
					MainIndexOf += '</div>'+//end brl
					'<div id="Location_CHI" style="display:none">'+
					'<center>';
					for(i = 1; i < Object.keys(CHIJobMap).length+1; i++){
						MainIndexOf += ' <a class="sexy_button_new purple short"><span><span id="ShowHide_CHI_'+i+'">D'+i+'</span></span></a> '
					}
					MainIndexOf += '</center>';
					for(i = 0; i < Object.keys(CHIJobMap).length; i++){
						MainIndexOf += '<div id="CHI_'+(i+1)+'" style="display:none">';
						for (ii = 0; ii < CHIJobMap[Object.keys(CHIJobMap)[i]].length; ii++) {
							MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:570px;float:left;"><div style="margin-top:5px;">' + CHIJobMap[Object.keys(CHIJobMap)[i]][ii].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_CHIJobs" class="sexy_button_new short green"><span><span id="CHI_'+(i+1)+'_' + ii + '">Add</span></span></a></span></div></span></li>'
						}
						MainIndexOf += '</div>';
					}
					MainIndexOf += '</div>'+//end CHI
					'<div id="Location_LON" style="display:none">'+
					'<center>';
					for(i = 1; i < Object.keys(LONJobMap).length+1; i++){
						MainIndexOf += ' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_'+i+'">D'+i+'</span></span></a> '
					}
					MainIndexOf += '</center>';
					for(i = 0; i < Object.keys(LONJobMap).length; i++){
						MainIndexOf += '<div id="LON_'+(i+1)+'" style="display:none">';
						for (ii = 0; ii < LONJobMap[Object.keys(LONJobMap)[i]].length; ii++) {
							MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:570px;float:left;"><div style="margin-top:5px;">' + LONJobMap[Object.keys(LONJobMap)[i]][ii].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_'+(i+1)+'_' + ii + '">Add</span></span></a></span></div></span></li>'
						}
						MainIndexOf += '</div>';
					}
					MainIndexOf += '</div>'+//end LON
					'<div id="Location_SA" style="display:none">'+
					'<center>';
					for(i = 1; i < Object.keys(SAJobMap).length+1; i++){
						MainIndexOf += ' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_'+i+'">D'+i+'</span></span></a> '
					}
					MainIndexOf += '</center>';
					for(i = 0; i < Object.keys(SAJobMap).length; i++){
						MainIndexOf += '<div id="SA_'+(i+1)+'" style="display:none">';
						for (ii = 0; ii < SAJobMap[Object.keys(SAJobMap)[i]].length; ii++) {
							MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:570px;float:left;"><div style="margin-top:5px;">' + SAJobMap[Object.keys(SAJobMap)[i]][ii].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_'+(i+1)+'_' + ii + '">Add</span></span></a></span></div></span></li>'
						}
						MainIndexOf += '</div>';
					}
					MainIndexOf += '</div>'+//end SA
					'<div id="Location_MEX" style="display:none">'+
					'<center>';
					for(i = 1; i < Object.keys(MEXJobMap).length+1; i++){
						MainIndexOf += ' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_'+i+'">D'+i+'</span></span></a> '
					}
					MainIndexOf += '</center>';
					for(i = 0; i < Object.keys(MEXJobMap).length; i++){
						MainIndexOf += '<div id="MEX_'+(i+1)+'" style="display:none">';
						for (ii = 0; ii < MEXJobMap[Object.keys(MEXJobMap)[i]].length; ii++) {
							MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:570px;float:left;"><div style="margin-top:5px;">' + MEXJobMap[Object.keys(MEXJobMap)[i]][ii].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_'+(i+1)+'_' + ii + '">Add</span></span></a></span></div></span></li>'
						}
						MainIndexOf += '</div>';
					}
					MainIndexOf += '</div>'+//end MEX
					'<div id="Location_LT" style="display:none">';
					if(SecretDistrictCounter > 0){
						for (i = 0; i < SecretDistrictCounter; i++) {
							MainIndexOf += '<a class="sexy_button_new short orange" id="'+SDMap[i].isTab+'"><span><span>'+SDMap[i].isName+'</span></span></a> <a id="GrabSD_'+i+'" class="sexy_button_new short black" style=""><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/action_box_icon_refresh.gif"></span></span></a><br><div id="'+SDMap[i].isTab+'_Jobs"></div>'
						}
					}else{
						MainIndexOf += 'No Secret District(s) detected, try reloading MW!'
					}
					MainIndexOf += '</div></span>'+//end LT
					'<span id="Stamina_Opt" style="display:none">'+
					'<a class="sexy_button_new short red"><span><span> Arena! </span></span></a><br>'+
					'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">Spartacus <span style="float:right;margin:-2px;margin-right:5px;"><a class="sexy_button_new short green" id="ADD_Sparty"><span><span id="DXSpart_">Add</span></span></a></span></div></span></li>'+
					'<br><br><a class="sexy_button_new short red"><span><span> Fighting! </span></span></a><br>'+
					'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">Fightlist Fighting In: <select id="DX_FightIn_Opts"><option value="1">New York</option><option value="7">Brazil</option><option value="8">Chicago</option><option value="9">London</option><option value="10">South Africa</option><option value="11">Mexico</option></select> <span style="float:right;margin:-2px;margin-right:5px;"><a class="sexy_button_new short green" id="ADD_Fight"><span><span id="DXFight_">Add</span></span></a></span></div></span></li>'+
					'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">Kami In: <select id="DX_KamiIn_Opts"><option value="1">New York</option><option value="7">Brazil</option><option value="8">Chicago</option><option value="9">London</option><option value="10">South Africa</option><option value="11">Mexico</option></select> <span style="float:right;margin:-2px;margin-right:5px;"><a class="sexy_button_new short green" id="ADD_Kami" style="display:none;"><span><span id="DXKami_">Add</span></span></a></span></div></span></li>'+
					'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">Player to Attack <span class="more_in">(Copy the link from a Player Profile Page) </span><span style="float:right;margin:-2px;margin-right:5px;"></span></div></span></li><li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111; background-color: black;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;"><section>'+
					'<input type="text" id="FAKE_target_url" value="https://apps.facebook.com/inthemafia/profile.php?id=" placeholder="https://apps.facebook.com/inthemafia/profile.php?id=" style="font-size: 11px; border: 0px; height:17px; background-color: black; color:#52E259; font-weight:bold; width:650px;" size="123">'+
					'<label for="FAKE_target_url" style="top: -19px;color: #52E259; float:right;display: block; position: relative;"><span id="profileGood"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/requests/cross.png" style="vertical-align: middle;height:24px;"></span></label>'+
					'</section></div></span></li>'+
					'<br><br><a class="sexy_button_new short red"><span><span> FOB Options </span></span></a>';
					for (i = 0; i < Object.keys(StamJobs)[3]; i++) {
						MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">' + StamJobs[i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_Fobs" class="sexy_button_new short green"><span><span id="SA_10_' + i + '">Add</span></span></a></span></div></span></li>'
					}
					for (i = 3; i < StamJobs.length; i++) {
						MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">' + StamJobs[i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_Fobs" class="sexy_button_new short green"><span><span id="MEX_10_' + i + '">Add</span></span></a></span></div></span></li>'
					}
					MainIndexOf += '<br><br><a class="sexy_button_new short red"><span><span> Robbing </span></span></a><br>'+
					'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">Rob In: <select id="DX_Rob_Opts"><option value="1">New York</option><option value="7">Brazil</option><option value="8">Chicago</option><option value="9">London</option><option value="10">South Africa</option><option value="11">Mexico</option></select> <span style="float:right;margin:-2px;margin-right:5px;"><a class="sexy_button_new short green" id="ADD_Rob"><span><span id="Rob_">Add</span></span></a></span></div></span></li>'+
					'</span>'+
					/*
					https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/quest/completed_mark_13x13_01.png
https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/quest/checkbox_complete_28x28_01.png
https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/requests/cross.png
					*/
					'</div>'+
				'<div style="display: none;" id="Zangano_JobList">'+
					'<center><a style="width:400px;" class="sexy_button_new short green"><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+Zangano.Imgs.EnergyIcon+'"> Resource Options <img src="'+Zangano.Imgs.StaminaIcon+'"></span></span></a> <a id="dragEm" class="sexy_button_new short black" style=""><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/quest/toughguy-icon.png" style="height:20px;width:20px;"></span></span></a></center>'+
					'<ul id="customjobs"></ul>'+
					'</div>'+
					'<div style="display: none;" id="Zangano_LootLog">'+
						'<table>'+
						'<tr>'+
							'<td width="50px" valign="top"><a href="#" id="log_show">Log</a> <input type="text" id="log_size" value="15" class="sexy_input" style="width:16px"></input></td>'+
							'<td width="1px" valign="top">:</td>' +
							'<td id="log" valign="top" colspan="2">Zangano Loaded...</td>'+
						'</tr>'+
						'</table>'+
						'<table>'+
						'<tr><td valign="top"><a href="#" id="ZX_Spart_toggleloot" title="Click to show/hide loot log">Loot/Stats:</a></td><td></td></tr>'+
							'<tr class="ZX_Spart_lootlog"><td valign=top>Stats:</td><td colspan="2"><span id="ZX_Spart_allstats"></span></td></tr>'+
							'<tr class="ZX_Spart_lootlog"><td valign=top>Loot:</td><td colspan="2" id="ZX_Spart_lootlog"></td></tr>'+
						'<tr><td valign="top"><a href="#" id="ZX_Spart_togglearenas" title="Click to show/hide arena log">Arenas:</a></td><td></td></tr>'+
							'<tr class="ZX_Spart_arenalog"><td valign=top></td><td colspan="2" id="ZX_Spart_arenalog"></td></tr>'+
						'</table>'+
					'</div>'+
					 '<div style="display: none; text-size:15px;" id="Zangano_ChangeLog">'+
						ChangeLogInfoz+
					'</div>'+
				'</div>'+
				'<span id="lastspan" class="energy_highlight" style="float:right"><img title="Made & tested on FireFox" style="width:20px;height:20px;" src="http://upload.wikimedia.org/wikipedia/en/e/e3/Firefox-logo.svg"><b>Powered by $.Woof()</b></span>'+				
			'</div>'+
		'</div>'+
	'</div> <span style="font-weight: bold;" class="energy_highlight">Feedback? Errors?</span> <span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="vertical-align: -2px;"></span></span><a target="_blank" href="https://www.facebook.com/messages/john.xsseu" style="font-weight: bold;">Facebook Message Me!</a></div>';
				
	function LoadZanganoMain() {
		$('#Zangano_MainTab').removeClass('Zangano_TabInActive').addClass('Zangano_TabActive');
		$('#Zangano_ConfigTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');	
		$('#Zangano_JobSetupTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobListTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_AllLootLog').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ChangeLogTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');		
		$('#Zangano_Config').css('display','none');
		$('#Zangano_JobSetup').css('display','none');
		$('#Zangano_JobList').css('display','none');
		$('#Zangano_LootLog').css('display','none');
		$('#Zangano_ChangeLog').css('display','none');
		$('#Zangano_Main').show();
	}

	function LoadZanganoConfig() {
		$('#Zangano_MainTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ConfigTab').removeClass('Zangano_TabInActive').addClass('Zangano_TabActive');		
		$('#Zangano_JobSetupTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobListTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_AllLootLog').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ChangeLogTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_Main').css('display','none');
		$('#Zangano_JobSetup').css('display','none');
		$('#Zangano_JobList').css('display','none');
		$('#Zangano_LootLog').css('display','none');
		$('#Zangano_ChangeLog').css('display','none');
		$('#Zangano_Config').show();
	}
	
	function LoadZanganoJobSetup() {
		$('#Zangano_MainTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ConfigTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobSetupTab').removeClass('Zangano_TabInActive').addClass('Zangano_TabActive');	
		$('#Zangano_JobListTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_AllLootLog').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ChangeLogTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_Main').css('display','none');
		$('#Zangano_Config').css('display','none');
		$('#Zangano_JobList').css('display','none');
		$('#Zangano_LootLog').css('display','none');	
		$('#Zangano_ChangeLog').css('display','none');
		$('#Zangano_JobSetup').show();
	}
	
	function LoadZanganoJobList() {
		$('#Zangano_MainTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ConfigTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobSetupTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobListTab').removeClass('Zangano_TabInActive').addClass('Zangano_TabActive');
		$('#Zangano_AllLootLog').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ChangeLogTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');		
		$('#Zangano_Main').css('display','none');
		$('#Zangano_Config').css('display','none');
		$('#Zangano_JobSetup').css('display','none');
		$('#Zangano_LootLog').css('display','none');
		$('#Zangano_ChangeLog').css('display','none');
		$('#Zangano_JobList').show();
	}
	function LoadZanganoLootLog(){
		$('#Zangano_MainTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ConfigTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobSetupTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobListTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_AllLootLog').removeClass('Zangano_TabInActive').addClass('Zangano_TabActive');
		$('#Zangano_ChangeLogTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');			
		$('#Zangano_Main').css('display','none');
		$('#Zangano_Config').css('display','none');
		$('#Zangano_JobSetup').css('display','none');
		$('#Zangano_JobList').css('display','none');
		$('#Zangano_ChangeLog').css('display','none');
		$('#Zangano_LootLog').show();
		
	}
	
	function LoadZanganoChangeLog() {
		$('#Zangano_MainTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ConfigTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobSetupTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_JobListTab').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_AllLootLog').removeClass('Zangano_TabActive').addClass('Zangano_TabInActive');
		$('#Zangano_ChangeLogTab').removeClass('Zangano_TabInActive').addClass('Zangano_TabActive');
		$('#Zangano_Main').css('display','none');
		$('#Zangano_Config').css('display','none');
		$('#Zangano_JobSetup').css('display','none');
		$('#Zangano_JobList').css('display','none');
		$('#Zangano_LootLog').css('display','none');
		$('#Zangano_ChangeLog').show();
	}
	
	create_div();
	
	$('#stop').click(function(){
		if(Zangano.isRunning){
			$('#stop').html('<span><span>GO!!!!</span></span>');
			$(this).addClass('green');
			$(this).removeClass('red');			
			Zangano.isRunning = false;
			fightRuning = false;
			if(arenaRunning){
				stopAFTR = true;
				loggerCentral($('#status').html(),'log');
				loggerCentral('Zangano Pausing after Arena finishes...', 'status');
			}else{
				loggerCentral($('#status').html(),'log');
				loggerCentral('Zangano Stopped...', 'status');
			}
		}else{
			$('#stop').html('<span><span>Stop!</span></span>');
			loggerCentral('Starting..', 'status');
			$(this).addClass('red');
			$(this).removeClass('green');
			stopAFTR = false;			
			Zangano.isRunning = true;
			setTimeout(function(){checkResources();},1000);
		}
	});

	function UpdateConfig(value) {
		var value = parseInt(value);
		value === 0 ? $("#DX_Job_Opts").show() : $("#DX_Job_Opts").hide(),
		value === 1 ? $("#DX_Bank_Opts").show() : $("#DX_Bank_Opts").hide(), 
		value === 2 ? $("#DX_Fight_Opts").show() : $("#DX_Fight_Opts").hide(), 
		value === 3 ? $("#DX_Spending_Opts").show() : $("#DX_Spending_Opts").hide(), 
		value === 4 ? $("#DX_Arena_Opts").show() : $("#DX_Arena_Opts").hide(), 
		value === 5 ? $("#DX_APost_Opts").show() : $("#DX_APost_Opts").hide(),
		value === 6 ? $("#DX_Misc_Opts").show() : $("#DX_Misc_Opts").hide()
	}
	
	$("#DX_Opts").change(function () {
		UpdateConfig(this.value);
	})
		
	UpdateConfig(document.getElementById("DX_Opts").selectedIndex);
	
	$('a[id^="Show_Opt_"]').live('click', function(){
		if($('#'+$(this).attr('id').split('_')[2]+'_Opt').css('display') !== 'none'){
			$('#'+$(this).attr('id').split('_')[2]+'_Opt').hide();
			return;
		}else{
			$("span[id$='_Opt']").hide();
			$('#'+$(this).attr('id').split('_')[2]+'_Opt').show();
		}
	})
	
	$('a[id^="Show_Location_"]').live('click', function(){
		if(document.getElementById('Location_'+$(this).attr('id').split('_')[2]).style.display !== 'none'){
			$('a[id^="Show_Location_"]').removeClass('white').addClass('black');
			$('div[id^="Location_"]').hide();
			return;
		}else{
			$('div[id^="Location_"]').hide();
			$('a[id^="Show_Location_"]').removeClass('white').addClass('black');
			if($(this).attr('id').split('_')[2] !== 'LT'){
				$('#Show_Location_'+$(this).attr('id').split('_')[2]).addClass('white');
			}
			$('#Location_'+$(this).attr('id').split('_')[2]).show();
		}
	})
	
	$('span[id^="ShowHide_"]').live('click', function(){
		if(document.getElementById($(this).attr('id').split('_')[1]+'_'+$(this).attr('id').split('_')[2]).style.display !== 'none'){
			$('#'+$(this).attr('id').split('_')[1]+'_'+$(this).attr('id').split('_')[2]).hide();
		}else{
			$('div[id^="NY_"]').hide();
			$('div[id^="BRL_"]').hide();
			$('div[id^="CHI_"]').hide();
			$('div[id^="LON_"]').hide();
			$('div[id^="SA_"]').hide();
			$('div[id^="MEX_"]').hide();
			$('#'+$(this).attr('id').split('_')[1]+'_'+$(this).attr('id').split('_')[2]).show();
		}
	})
	
	$('a[id^="GrabSD_"]').live('click', function(){
		var grabbedID = $(this).attr('id').split('_')[1];
//		making an array for it was to hard, might come back to it tho
		document.getElementById(SDMap[grabbedID].isTab+'_Jobs').innerHTML = '';
		AjxRequest('xw_controller=travel&xw_action=travel&from=job&destination='+SDMap[$(this).attr('id').split('_')[1]].isCity+'&tab='+SDMap[$(this).attr('id').split('_')[1]].isTab,function(page){
			$(page).find('.job').each(function(index){
				var GetName = $(this).find('h4').text().trim();
				var energy = $(this).find('.uses.clearfix').find('.energy').attr('current_value');
				var experience = $(this).find('.pays.clearfix').find('.experience').attr('current_value');
				var link = $(this).find('a[id^="btn_dojob_"]').attr('href');
				var jobidz = /job=(\d+)/.exec(link)[1];
				$('#'+SDMap[grabbedID].isTab+'_Jobs').append('<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:570px;float:left;"><div style="margin-top:5px;">' + GetName + ' ('+(experience/energy).toFixed(3)+')<span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LTDJobs" class="sexy_button_new short green"><span><span id="LTD_'+SDMap[grabbedID].isCity+'_'+SDMap[grabbedID].isTab+'_' + jobidz + '">Add</span></span></a></span></div></span></li>')
			});
//			logit(JSON.stringify(Zangano.SD, null, 0))
		});
	})

	$('#ADD_NYJOB, #ADD_BRLJOB, #ADD_CHIJobs, #ADD_LONJobs, #ADD_SAJobs, #ADD_MEXJobs, #ADD_LTDJobs, #ADD_Fobs').live('click', function(){
		if($('ul#customjobs li a[id*="'+$(this).children().children().attr('id')+'"]').length > 0 && $('ul#customjobs li:contains("'+$(this).parent().parent().get(0).firstChild.nodeValue+'")').text()) {
			$(this).removeClass('red').addClass('green');
			$(this).children().children().text('Add');
			$('ul#customjobs li:contains("'+$(this).parent().parent().get(0).firstChild.nodeValue+'")').remove();
		}else{
			//	$(this).parent().parent().text().slice(0,-3)
			//if($(this).parent().parent().get(0).firstChild.nodeValue.match(/(Gain The Cooperation|Double Cross And|Offer Restitution)/)){
			//	$(this).parent().parent().parent().parent().get(0).firstChild.nodeValue
			//$('#customjobs #SA_10_0').parent().parent().get(0).firstChild.nodeValue;
			//$('#SA_10_0').parent().parent().parent().parent().get(0).firstChild.nodeValue;
			//alert($('#SA_10_0').children().children().attr('id'))
			$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:570px;float:left;">'+$(this).parent().parent().get(0).firstChild.nodeValue+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="'+$(this).children().children().attr('id')+'">X</a></span></span><a title="Add/Remove Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:336px;float:left;">Change to next job when resource is under:<input type="integer" style="resize:none;width:50px;" value="100000"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="2.27"></span>'));
			//
			$(this).removeClass('green').addClass('red');
			$(this).children().children().text('Remove It');
		}
	});
	
	$('#ADD_Rob').live('click', function(){
		if($('ul#customjobs a[id*="ROB_"]').length > 0) {
			$(this).removeClass('red').addClass('green');
			$(this).children().children().text('Add');
			$('ul#customjobs li:contains("Rob In")').remove();
		}else{
			$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:570px;float:left;">Rob In '+$("#DX_Rob_Opts > option:selected").text()+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="ROB_'+$("#DX_Rob_Opts > option:selected").val()+'">X</a></span></span>'));
			//<a title="Add/Remove Energy Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Ratio Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:330px;float:left;">Change to next job when energy is under:<input type="integer" style="resize:none;width:50px;" value="100000"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="2.27"></span>
			$(this).removeClass('green').addClass('red');
			$(this).children().children().text('Remove It');
		}
	});
	
	$('#ADD_Sparty').live('click', function(){
	//	alert('Sorry Spartacus is not currently coded in, please chose something else');
	//	return;
		if($('ul#customjobs a[id*="DXSpart_"]').length > 0) {
			$(this).removeClass('red').addClass('green');
			$(this).children().children().text('Add');
			$('ul#customjobs li:contains("Arena")').remove();
		}else{
			$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:570px;float:left;">Arena <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="DXSpart_">X</a></span></span>'));
			//<a title="Add/Remove Energy Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Ratio Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:330px;float:left;">Change to next job when energy is under:<input type="integer" style="resize:none;width:50px;" value="100000"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="2.27"></span>
			$(this).removeClass('green').addClass('red');
			$(this).children().children().text('Remove It');
		}
	});
		
	$('#ADD_Fight').live('click', function(){
//		alert('Sorry fighting is not currently coded in, please chose something else');
//		return;
		if($('ul#customjobs a[id*="DXFight_"]').length > 0) {
			$(this).removeClass('red').addClass('green');
			$(this).children().children().text('Add');
			$('ul#customjobs li:contains("Fight In")').remove();
		}else{
			$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:570px;float:left;">Fight In '+$("#DX_FightIn_Opts > option:selected").text()+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="DXFight_'+$("#DX_FightIn_Opts > option:selected").val()+'">X</a></span></span>'));
			//<a title="Add/Remove Energy Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Ratio Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:330px;float:left;">Change to next job when energy is under:<input type="integer" style="resize:none;width:50px;" value="100000"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="2.27"></span>
			$(this).removeClass('green').addClass('red');
			$(this).children().children().text('Remove It');
		}
	});	
	
	$('#ADD_Kami').live('click', function(){
//		alert('Sorry fighting is not currently coded in, please chose something else');
//		return;
		if($('ul#customjobs a[id*="DXKami_"]').length > 0) {
			$(this).removeClass('red').addClass('green');
			$(this).children().children().text('Add');
			$('ul#customjobs li:contains("Kami")').remove();
		}else{
			$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:570px;float:left;">Kami In '+$("#DX_KamiIn_Opts > option:selected").text()+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="DXKami_'+$("#DX_KamiIn_Opts > option:selected").val()+'">X</a></span></span>'));
			//<a title="Add/Remove Energy Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Ratio Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:330px;float:left;">Change to next job when energy is under:<input type="integer" style="resize:none;width:50px;" value="100000"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="2.27"></span>
			$(this).removeClass('green').addClass('red');
			$(this).children().children().text('Remove It');
		}
	});		
	
	$('.clearitem').live('click', function(){
		if($(this).attr('id').slice(0,-1) == 'ROB_'){
			$('#ADD_Rob').removeClass('red').addClass('green');
			$('#ADD_Rob').children().children().text('Add');		
		}else if($(this).attr('id').slice(0,-1) == 'DXFight_'){
			$('#ADD_Fight').removeClass('red').addClass('green');
			$('#ADD_Fight').children().children().text('Add');		
		}else if($(this).attr('id') == 'DXSpart_'){
			$('#ADD_Sparty').removeClass('red').addClass('green');
			$('#ADD_Sparty').children().children().text('Add');		
		}else if($(this).attr('id').slice(0,-1) == 'DXKami_'){
			$('#ADD_Kami').removeClass('red').addClass('green');
			$('#ADD_Kami').children().children().text('Add');		
		}else{
			if($(this).parent().parent().get(0).firstChild.nodeValue.match(/(Gain The Cooperation|Double Cross And|Offer Restitution|Send Your Partner|Sabotage The Bull|Use His Death)/)){
				$('#ADD_Fobs #'+$(this).attr('id')).parent().parent().removeClass('red').addClass('green');
				$('#ADD_Fobs #'+$(this).attr('id')).text('Add');
			}else{
				$("#"+$(this).attr('id')).parent().parent().removeClass('red').addClass('green');
				$("#"+$(this).attr('id')).text('Add');
			}
		}
		$(this).parent().parent().parent().next("span").remove();		
		$(this).parent().parent().parent().remove();	
		return false;
	});
	
	$("#JobEnergyTill").live('click', function(){
		$(this).parent().children().last().hide();
		$(this).parent().children().last().prev().toggle();
		return false;
	});
		
	$("#JobRatios").live('click', function(){
		$(this).parent().children().last().prev().hide();
		$(this).parent().children().last().toggle();
		return false;
	});
	
	$('#dragEm').live('click', function(){
		if(!SortLists){
			$('#customjobs').sortable();
			$('#customjobs').disableSelection();	
			$(this).removeClass('black').addClass('red');
			SortLists = true;
		}else{
			$(this).removeClass('red').addClass('black');
			$('#customjobs').sortable('destroy');
			$('#customjobs').enableSelection();
			SortLists = false;
		}
	});
	
	$('#JobList').parent().hover(
		function () {
			$(this).css("overflow","auto");
			$(this).css("padding-right","1px");
		}, 
		function () {
			$(this).css("overflow","hidden");
			$(this).css("padding-right","");
		}
	);	
	
/*	document.getElementById("DX_Rob_Opts").options[1].disabled = "disabled";
	document.getElementById("DX_Rob_Opts").options[2].disabled = "disabled";
	document.getElementById("DX_Rob_Opts").options[3].disabled = "disabled";
	document.getElementById("DX_Rob_Opts").options[4].disabled = "disabled";
	document.getElementById("DX_Rob_Opts").options[5].disabled = "disabled";
	document.getElementById("DX_FightIn_Opts").options[1].disabled = "disabled";
	document.getElementById("DX_FightIn_Opts").options[2].disabled = "disabled";
	document.getElementById("DX_FightIn_Opts").options[3].disabled = "disabled";
	document.getElementById("DX_FightIn_Opts").options[4].disabled = "disabled";
	document.getElementById("DX_FightIn_Opts").options[5].disabled = "disabled";*/
	
//	$("#DX_Opts option[value='2']").attr('disabled', true ); 
//	$("#DX_Opts option[value='4']").attr('disabled', true ); 
	$("#DX_Opts option[value='5']").attr('disabled', true ); 
	$("#DX_Opts option[value='6']").attr('disabled', true ); 
	$('#ADD_SAJobs #SA_10_0').parent().parent().parent().parent().parent().parent().hide()
	$('#ADD_SAJobs #SA_10_3').parent().parent().parent().parent().parent().parent().hide()
	$('#ADD_SAJobs #SA_10_6').parent().parent().parent().parent().parent().parent().hide()
	$('#ADD_MEXJobs #MEX_10_2').parent().parent().parent().parent().parent().parent().hide() 
	$('#ADD_MEXJobs #MEX_10_4').parent().parent().parent().parent().parent().parent().hide() 
	$('#ADD_MEXJobs #MEX_10_7').parent().parent().parent().parent().parent().parent().hide()
	$('#DX_FightIn_Opts').val(Zangano.Saving.FightCity);
	$('#DX_Rob_Opts').val(Zangano.Saving.RobCity);
	$('#ZX_noResources').val(Zangano.Saving.NoResourceMenu);
	//Recommended Jobs
	$('#NY_9 #NY_9_5').parent().parent().parent().parent().parent().css('background-color','#003300');
	$('#LON_8 #LON_8_5').parent().parent().parent().parent().parent().css('background-color','#003300');
	$('#SA_10 #SA_10_5').parent().parent().parent().parent().parent().css('background-color','#003300');
	$('#SA_10 #SA_10_9').parent().parent().parent().parent().parent().css('background-color','#003300');
	$('#MEX_8 #MEX_8_6').parent().parent().parent().parent().parent().css('background-color','#003300');
	$('#MEX_10 #MEX_10_5').parent().parent().parent().parent().parent().css('background-color','#003300');
	$('#Stamina_Opt #SA_10_2').parent().parent().parent().parent().parent().css('background-color','#003300');
	$('#Stamina_Opt #MEX_10_4').parent().parent().parent().parent().parent().css('background-color','#003300');
	
	jobSpeedSelector = function (n) {
		if (Zangano.Saving.jobSpeedMenu != n) {
			Zangano.Saving.jobSpeedMenu = n;
		}
		switch (parseInt(n)) {
			case 0:
				Zangano.Saving.jobSpeed = 500;
				break;
			case 1:
				Zangano.Saving.jobSpeed = 800;
				break;
			case 2:
				Zangano.Saving.jobSpeed = 1000;
				break;	
			case 3:
				Zangano.Saving.jobSpeed = 1500;
				break;		
		}
	};

	BanditXPCheck = function(n){
		if (Zangano.Saving.BanditXPCheck != n){
			Zangano.Saving.BanditXPCheck = n;
		}
		switch(parseInt(n)){
			case 0:
				Zangano.Saving.BanditElapsedTimerXP = 4;
				break;
			case 1:
				Zangano.Saving.BanditElapsedTimerXP = 1;
				break;
			case 2:
				Zangano.Saving.BanditElapsedTimerXP = 2;
				break;
			case 3:
				Zangano.Saving.BanditElapsedTimerXP = 3;
				break;
		}
	};
   
	BanditCSHCheck = function(n){
		if (Zangano.Saving.BanditCSHCheck != n){
			Zangano.Saving.BanditCSHCheck = n;
		}
		switch(parseInt(n)){
			case 0:
				Zangano.Saving.BanditElapsedTimerCash = 4;
				break;
			case 1:
				Zangano.Saving.BanditElapsedTimerCash = 4;
				break;
			case 2:
				Zangano.Saving.BanditElapsedTimerCash = 1;
				break;
			case 3:
				Zangano.Saving.BanditElapsedTimerCash = 2;
				break;
			case 4:
				Zangano.Saving.BanditElapsedTimerCash = 3;
				break;
		}
	};
   
	BanditJOBCheck = function(n){
		if (Zangano.Saving.BanditJOBCheck != n){
			Zangano.Saving.BanditJOBCheck = n;
		}
	};	
	
	SkillSpending = function (n) {
		if (Zangano.Saving.SkillSpendingMenu != n) {
			Zangano.Saving.SkillSpendingMenu = n;
		}
		switch (parseInt(n)) {
			case 0:
				SkillToSpend = 'none';
				SkillsTo = 'None';
				break;
			case 1:
				SkillToSpend = 'attack';
				SkillsTo = '<img src="' + Zangano.Imgs.AttackIcon + '"> Attack!';
				break;
			case 2:
				SkillToSpend = 'defense';
				SkillsTo = '<img src="' + Zangano.Imgs.DefenseIcon + '"> Defense!';
				break;
			case 3:
				SkillToSpend = 'max_health';
				SkillsTo = '<img src="' + Zangano.Imgs.HealthIcon + '"> Health!';
				break;
			case 4:
				SkillToSpend = 'max_energy';
				SkillsTo = '<img src="' + Zangano.Imgs.EnergyIcon + '"> Energy!';
				break;
			case 5:
				SkillToSpend = 'max_stamina';
				SkillsTo = '<img src="' + Zangano.Imgs.StaminaIcon + '"> Stamina!';
				break;
		}
		if(parseInt(n) > 0){
			$('#ZX_spendSkillsWhen').show();
		}else{
			$('#ZX_spendSkillsWhen').hide();
		}
	};
	
	$('#ZX_jobSpeed option:eq(' + Zangano.Saving.jobSpeedMenu + ')').prop('selected', true);
	jobSpeedSelector(Zangano.Saving.jobSpeedMenu);
	
	$('#XPBanO option:eq('+Zangano.Saving.BanditXPCheck+')').prop('selected', true);
	BanditXPCheck(Zangano.Saving.BanditXPCheck);
   
	$('#CSHBanO option:eq('+Zangano.Saving.BanditCSHCheck+')').prop('selected', true);
	BanditCSHCheck(Zangano.Saving.BanditCSHCheck);
   
	$('#JOBBanO option:eq('+Zangano.Saving.BanditJOBCheck+')').prop('selected', true);
	BanditJOBCheck(Zangano.Saving.BanditJOBCheck);
	
	$('#ZX_skillSpending option:eq(' + Zangano.Saving.SkillSpendingMenu + ')').prop('selected', true);
	SkillSpending(Zangano.Saving.SkillSpendingMenu);
	
	$('#ZX_noResources').change(function(){
		if(this.selectedIndex == 0) {
			$('#ZX_restartSpan').hide();
			$('#ZX_idleCitySpan').show();
		}else if(this.selectedIndex == 1){ 
			$('#ZX_restartSpan').show();
			$('#ZX_idleCitySpan').hide();
		}else {
			$('#ZX_restartSpan').hide();
			$('#ZX_idleCitySpan').hide();
		}
		Zangano.Saving.NoResourceMenu = this.selectedIndex;
//		writeSettings();
	}).trigger('change');
	
	$('#close').click(function(){
		clearInterval(refreshSigTimer);
		arenaRunning = false;
		Zangano.isRunning = false;
		closed = true;
		try {
			socke.close();
		} catch(noopenedyet) {}
		$('#gxDiv').remove();
	});
	
	BGCheck = function(n){
		if (Zangano.Saving.BG != n){
			Zangano.Saving.BG = n;
		}
		switch(parseInt(n)){
			case 0:
			document.getElementById('BGS').style.background = 'url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/mexico_hp_bg.jpg)  no-repeat'; 
			break;
			case 1:
			document.getElementById('BGS').style.background = 'url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/london_hp_bg.png)  no-repeat'; 
			break;
			case 2:
			document.getElementById('BGS').style.background = 'url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/crafters_choice/hellish_hydraulics/popup_bg.jpg)  no-repeat'; 
			document.getElementById('BGS').style.backgroundSize = '100% 100%';
			break;
			case 3:
			document.getElementById('BGS').style.background = 'url(http://file1.hpage.com/004925/76/bilder/wallpaper-2.jpg)  no-repeat'; 
			document.getElementById('BGS').style.backgroundSize = '100% 100%';
			break;
			case 4:
			document.getElementById('BGS').style.background = 'url(http://file1.hpage.com/004925/76/bilder/wallpaper-1.jpg)  no-repeat'; 
			document.getElementById('BGS').style.backgroundSize = '100% 100%';
			break;
			case 5:
			document.getElementById('BGS').style.background = ''; 
			document.getElementById('BGS').style.backgroundColor = 'black'; 
			document.getElementById('BGS').style.backgroundSize = '';
			break;
		}
	};
	
	$('#BGC option:eq('+Zangano.Saving.BG+')').prop('selected', true);
		BGCheck(Zangano.Saving.BG);
		
	$("#start").live('click', function(){
		var ArrayIndexNum = 0;
		//$('#customjobs li a').each(function(index){
		/*Novel: 
			So why did i use a for loop instead of jquery each? 
			well im glad you asked that! 
			jquery decided to be dumb and skip over certain elements. 
			really? 
			yes really, it took me hours to figure it out and as soon as i changed it, it worked like it was meant to, wtf!*/
		GetJobInfoLoop:
		for(var i = 0; i < $('#customjobs li a').length; i++){
			if($('#customjobs li a').eq(i).attr('id') == 'JobRatios' || $('#customjobs li a').eq(i).attr('id') == 'JobEnergyTill'){
				continue GetJobInfoLoop;
			}
			var Ratioing;//$(this).parent().children().last().prev()
			var RatioingJobValue = '0.00';
			var NRGSwitch;
			var NRGSwitchValue;
			if($('#customjobs li a').eq(i).parent().parent().parent().children().last().css('display') == 'none'){ //Ratioing is off ResourceSwitchingOn ResourceSwitchVal
				Ratioing = false;
			}else{
				Ratioing = true;
				var jrv = parseFloat($('#customjobs li a').eq(i).parent().parent().parent().children().last().children('input').val());
				RatioingJobValue = jrv.toPrecision(3);
			}
			if($('#customjobs li a').eq(i).parent().parent().parent().children().last().prev().css('display') == 'none'){ //NRGSwitch is off
				NRGSwitch = false;
			}else{
				NRGSwitch = true;
				NRGSwitchValue = parseInt($('#customjobs li a').eq(i).parent().parent().parent().children().last().prev().children('input').val());
			}	
			var new_job;
			var isUsingStam;
			if($('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue.match("Gain The Cooperation")||$('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue.match("Double Cross And")||$('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue.match("Offer Restitution")||$('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue.match("Send Your Partner")||$('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue.match("Sabotage The Bull")||$('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue.match("Use His Death")||$('#customjobs li a').eq(i).attr('id').slice(0,-1) == 'ROB_'||$('#customjobs li a').eq(i).attr('id').slice(0,-1) == 'DXFight_'||$('#customjobs li a').eq(i).attr('id').slice(0,-1) == 'DXKami_'||$('#customjobs li a').eq(i).attr('id') == 'DXSpart_'){
				isUsingStam = true;
			}else{
				isUsingStam = false;
			}			
			var info = $('#customjobs li a').eq(i).attr('id').split('_');
			var city = info[0];
			var district = 'D'+parseInt(info[1]);
			try{
				var job = parseInt(info[2]);
			}catch(noOneLikesRobbing){}
			if(city == 'NY'){
				new_job = {isName: NYJobMap[district][job].isName, isID: NYJobMap[district][job].isJobID, isCost: 0, isTab: NYJobMap[district][job].isTab, isCity: NYJobMap[district][job].isCity, RatioSwitchingOn:Ratioing, RatioSwitchVal:RatioingJobValue, ResourceSwitchingOn:NRGSwitch, ResourceSwitchVal:NRGSwitchValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'BRL'){
				new_job = {isName: BRLJobMap[district][job].isName, isID: BRLJobMap[district][job].isJobID, isCost: 0, isTab: BRLJobMap[district][job].isTab, isCity: BRLJobMap[district][job].isCity, RatioSwitchingOn:Ratioing, RatioSwitchVal:RatioingJobValue, ResourceSwitchingOn:NRGSwitch, ResourceSwitchVal:NRGSwitchValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'CHI'){
				new_job = {isName: CHIJobMap[district][job].isName, isID: CHIJobMap[district][job].isJobID, isCost: 0, isTab: CHIJobMap[district][job].isTab, isCity: CHIJobMap[district][job].isCity, RatioSwitchingOn:Ratioing, RatioSwitchVal:RatioingJobValue, ResourceSwitchingOn:NRGSwitch, ResourceSwitchVal:NRGSwitchValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'LON'){
				new_job = {isName: LONJobMap[district][job].isName, isID: LONJobMap[district][job].isJobID, isCost: 0, isTab: LONJobMap[district][job].isTab, isCity: LONJobMap[district][job].isCity, RatioSwitchingOn:Ratioing, RatioSwitchVal:RatioingJobValue, ResourceSwitchingOn:NRGSwitch, ResourceSwitchVal:NRGSwitchValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'SA'){
				var properButton = SAJobMap[district][job].isJobID;
				var properName = SAJobMap[district][job].isName
				if(isUsingStam){
					properButton = StamJobs[job].isJobID;
					properName = StamJobs[job].isName;
				}
				new_job = {isName: properName, isID: properButton, isCost: 0, isTab: SAJobMap[district][job].isTab, isCity: SAJobMap[district][job].isCity, RatioSwitchingOn:Ratioing, RatioSwitchVal:RatioingJobValue, ResourceSwitchingOn:NRGSwitch, ResourceSwitchVal:NRGSwitchValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'MEX'){
				var properButton = MEXJobMap[district][job].isJobID;
				var properName = MEXJobMap[district][job].isName
				if(isUsingStam){
					properButton = StamJobs[job].isJobID;
					properName = StamJobs[job].isName;
				}			
				new_job = {isName: properName, isID: properButton, isCost: 0, isTab: MEXJobMap[district][job].isTab, isCity: MEXJobMap[district][job].isCity, RatioSwitchingOn:Ratioing, RatioSwitchVal:RatioingJobValue, ResourceSwitchingOn:NRGSwitch, ResourceSwitchVal:NRGSwitchValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'ROB'){
				new_job = {isName: $('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue, isID: 0, isTab: "robbing", isCity: parseInt(info[1]), isCost: 25, RatioSwitchingOn:false, RatioSwitchVal:RatioingJobValue, isStam: isUsingStam, isRobbing:true, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'DXFight'){
				new_job = {isName: $('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue, isID: 0, isTab: "fight", isCity: parseInt(info[1]), isCost: 75, RatioSwitchingOn:false, RatioSwitchVal:RatioingJobValue, isStam: isUsingStam, isRobbing:false, isFighting:true, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'DXSpart'){ 
				$('#doTheSpartDiv').show();
				new_job = {isName: $('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue, isID: 0, isTab: "fight", isCity: parseInt(info[1]), isCost: parseInt($("#ZX_Spart_arenatype > option:selected").text()), RatioSwitchingOn:false, RatioSwitchVal:RatioingJobValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:true, ArrayIndex:ArrayIndexNum};
			}else if(city == 'DXKami'){
				new_job = {isName: $('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue, isID: 0, isTab: "fight", isCity: parseInt(info[1]), isCost: 75, RatioSwitchingOn:false, RatioSwitchVal:RatioingJobValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:true, isArena:false, ArrayIndex:ArrayIndexNum};
			}else if(city == 'LTD'){
				new_job = {isName: $('#customjobs li a').eq(i).parent().parent().get(0).firstChild.nodeValue, isID:info[3], isCost: 0, isTab:info[2], isCity:info[1], RatioSwitchingOn:Ratioing, RatioSwitchVal:RatioingJobValue, ResourceSwitchingOn:NRGSwitch, ResourceSwitchVal:NRGSwitchValue, isStam: isUsingStam, isRobbing:false, isFighting:false, isKami:false, isArena:false, ArrayIndex:ArrayIndexNum};
			}
			ArrayIndexNum++;
			Zangano.JobMap.push(new_job);
		}
		if(Zangano.JobMap.length < 1){
			alert('You must add at least one job');
			return;
		}		
		Zangano.isRunning = true;
		$('#Zangano_MainTab').click();
		$('#Zangano_JobSetupTab .Zangano_TabMiddle').prepend(' <img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif" style="height:18px;width:18px;text-align:center;margin:-3px;">');
		$('#Zangano_JobListTab .Zangano_TabMiddle').prepend(' <img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif" style="height:18px;width:18px;text-align:center;margin:-3px;">');
		$("#Zangano_JobSetupTab").attr("onclick","");
		$("#Zangano_JobListTab").attr("onclick","");
		$('#start').hide();
		$('#stop').show();
		setTimeout(function(){grabInfoz();},1000);
		return false;
	});
	
	function grabInfoz(){
		if(!Zangano.isRunning){
			return;
		}
		CloseDoopidPopup();
		loggerCentral('Grabbing Requirements...', 'status');
		if(JobMapCount < Zangano.JobMap.length){
			if(Zangano.JobMap[JobMapCount].isCost == 0){
				$('#inAction').html('Grabbing Requirements for '+Zangano.JobMap[JobMapCount].isName);
				AjxRequest('xw_controller=travel&xw_action=travel&from=job&destination='+Zangano.JobMap[JobMapCount].isCity+'&tab='+Zangano.JobMap[JobMapCount].isTab,function(page){
						var JobInfo;
						var energy; 
						var stamina;
						var exp;
						if(Zangano.JobMap[JobMapCount].isCity < 5) {
							JobInfo = $(page).find('#city_job_' + Zangano.JobMap[JobMapCount].isID);
							energy = parseInt($(JobInfo).find('.energy').text()) || 0; 
							stamina = 0;
							exp = parseInt($(JobInfo).find('.experience').text()) || 0;
							try{
								var getmastery = $(page).find('#city_job_' + Zangano.JobMap[JobMapCount].isID + ' > .job_name').text();
								if(/Level 3 Mastered/.test(getmastery)){
									//Gold mastery
									Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.GoldStar;
								}else if(/Level 2 Mastered/.test(getmastery)){
									//Silver mastery
									Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.SilverStar;
								}else{
									//Bronze mastery
									Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.BronzeStar;
								}
							}catch(none){
								loggerCentral('null mastery?', 'debug');
								Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.GoldStar;
							}
						}else{
							JobInfo = $(page).find('#job-id-'+ Zangano.JobMap[JobMapCount].isID);
							energy = parseInt($(JobInfo).find('li.energy:last').attr('current_value')) || 0; 
							stamina = parseInt($(JobInfo).find('li.stamina:last').attr('current_value')) || 0;
							exp = parseInt($(JobInfo).find('li.experience:last').attr('current_value'));
							try{
								var MasteredSoFar = $(page).find('div[id^="brazil_district_'+Zangano.JobMap[JobMapCount].isTab+'"]').attr('class');
								if(parseInt(MasteredSoFar.match(/\d+$/)[0]) == 4){
									//ruby mastery
									Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.RubyStar;
								}else if(parseInt(MasteredSoFar.match(/\d+$/)[0]) == 3){
									//Gold mastery
									Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.GoldStar;
								}else if(parseInt(MasteredSoFar.match(/\d+$/)[0]) == 2){
									//Silver mastery
									Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.SilverStar;
								}else if(parseInt(MasteredSoFar.match(/\d+$/)[0]) == 1){
									//Bronze mastery
									Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.BronzeStar;
								}
							}catch(none){
								loggerCentral('null mastery?', 'debug');
								Zangano.JobMap[JobMapCount].isMastered = Zangano.Imgs.RubyStar;
							}
						}
						var pool = (energy > 0 ? energy : stamina);
						Zangano.JobMap[JobMapCount].isCost = parseInt(pool);
						Zangano.JobMap[JobMapCount].isExp = parseInt(exp);
						Zangano.JobMap[JobMapCount].isRatio = (Zangano.JobMap[JobMapCount].isExp/Zangano.JobMap[JobMapCount].isCost).toFixed(3);
						loggerCentral('Requirements found!', 'status');
						setTimeout(function(){grabInfoz();},500);
					},function(fail){
						if(fail.status == '500' && fail.statusText == 'error'){
							setTimeout(function(){grabInfoz();},1000);
						}
					}
				);
				return;
			}else{
				JobMapCount++;
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
		}
		if(isFirstLoad){
			isFirstLoad = false;
			document.getElementById('JobList').innerHTML = '';
			for(var i = 0; i < Zangano.JobMap.length; i++){
				if(Zangano.JobMap[i].isName.match("Rob In")){
					document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:704px; margin:1px;"><img src="'+Zangano.Imgs.FamilyIcon+'">'+ Zangano.JobMap[i].isName+' <span style="float:right; position:relative; right:140px; top:1px; width:55px;"><img src="'+Zangano.Imgs.StaminaIcon+'">'+ Zangano.JobMap[i].isCost+'</span></li>';
				}else if(Zangano.JobMap[i].isName.match("Fight In")){
					document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:704px; margin:1px;"><img src="'+Zangano.Imgs.FamilyIcon+'">'+ Zangano.JobMap[i].isName+' <img src="'+Zangano.Imgs.StaminaIcon+'">'+ Zangano.JobMap[i].isCost+' <span style="float:right; text-align:right;width:180px;"><Span class="good">Won: </span><span id="ZX_won">0</span>&nbsp;&nbsp;<span class="good">Lost: </span><span id="ZX_lost">0</span></span></li>';
				}else if(Zangano.JobMap[i].isName.match("Kami In")){
					document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:704px; margin:1px;"><img src="'+Zangano.Imgs.FamilyIcon+'">'+ Zangano.JobMap[i].isName+' <img src="'+Zangano.Imgs.StaminaIcon+'">'+ Zangano.JobMap[i].isCost+'</li>';
				}else if(Zangano.JobMap[i].isName.match("Arena")){
					document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:704px; margin:1px;"><img src="'+Zangano.Imgs.FamilyIcon+'">'+ Zangano.JobMap[i].isName+' <img src="'+Zangano.Imgs.StaminaIcon+'">'+ Zangano.JobMap[i].isCost+'</li>';
				}else{
					var GetName = parseStuff(Zangano.JobMap[i].isName);
					Zangano.JobMap[i].isName = GetName.name;
//					Zangano.JobMap[i].isRatio = GetName.ratio;
					if(Zangano.JobMap[i].isStam){
						document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:704px; margin:1px;"><img title="Job Mastery" src="'+Zangano.JobMap[i].isMastered+'">'+ Zangano.JobMap[i].isName+' ('+Zangano.JobMap[i].isRatio+')<span style="float:right; position:relative; right:140px; top:1px; width:55px;"> <img src="'+Zangano.Imgs.StaminaIcon+'">'+ Zangano.JobMap[i].isCost+'</span> <span style="float:right; position:relative; right:0px; top:-1px; width:55px;"><img src="'+Zangano.Imgs.ExpIcon+'">'+Zangano.JobMap[i].isExp+' </span><span style="float:right; position:relative; right:-126px; top:1px; width:55px;text-align:right">x<span title="Amount of times this job has been attempted" id="JobCounter_'+Zangano.JobMap[i].isID+'">0</span></span></li>';
					}else{
						document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:704px; margin:1px;"><img title="Job Mastery" src="'+Zangano.JobMap[i].isMastered+'">'+ Zangano.JobMap[i].isName+' ('+Zangano.JobMap[i].isRatio+')<span style="float:right; position:relative; right:140px; top:1px; width:55px;"> <img title="Job Costs" src="'+Zangano.Imgs.EnergyIcon+'">'+ Zangano.JobMap[i].isCost+'</span> <span style="float:right; position:relative; right:0px; top:-1px; width:55px;"><img title="Job Pays" src="'+Zangano.Imgs.ExpIcon+'">'+Zangano.JobMap[i].isExp+' </span><span style="float:right; position:relative; right:-126px; top:1px; width:55px;text-align:right">x<span title="Amount of times this job has been attempted" id="JobCounter_'+Zangano.JobMap[i].isID+'">0</span></span></li>';
					}
				}
			}
		}
		setTimeout(function(){checkResources();},100);
	}
		//704 140 0 126
	function parseStuff(str) { // By Esa
		var re = /^(.*?)\(([0-9.]+)\)/
		var matches = str.match( re );
		if( matches && matches.length == 3 ) {
			return {
				name: matches[1],
				ratio: parseFloat(matches[2]).toFixed(3)
			}
		}
		return null;
	}		
/*end the going thru*/		
	function doTravel(destination, from, tab, callback) {
		if(!Zangano.isRunning){
			return;
		}
		loggerCentral('Traveling..', 'status');
		CloseDoopidPopup();
		var pageLoadSpeed;
		if(jobArray[0].isRobbing){
			pageLoadSpeed = 1500;
		}else{
			pageLoadSpeed = 2000;
		}
		var fromCity = CurrentCity();
		var url = 'html_server.php?xw_controller=travel&xw_action=travel';
		var data = {
			'ajax': 1,
			'liteload': 1,
			'sf_xw_user_id': userId,
			'sf_xw_sig': local_xw_sig,  
			'cb': userId+unix_timestamp(),
			'xw_client_id': 8,
			'destination': destination || 1,
			'from': from || 'job',
			'tab': tab || 1,
			'zone': 1
		};
		if(tab == 'robbing'){
			delete data.tab;	
		}
		Zangano.banditInfo.banditsActive = false;
		Zangano.banditInfo.backUpBanditTimer = 6;
		$.ajax({
			url:url,
			data:data,
			timeout: 45000,
			success: function (htmlText) {
				var $htmlText = $(htmlText);
				$('#inner_page').empty();
				$('#inner_page').html(htmlText);
				loggerCentral('Setting up page..', 'status');
				User.page = setCurrentCity(htmlText);
				if (fromCity != (CurrentCity($htmlText))) {
					if(!Zangano.isRunning){
						return;
					}
					if (typeof callback == 'function'){
						setTimeout(function(){
							callback && callback();
						},pageLoadSpeed);
					}
				}
			},
			error: function (E){
				setTimeout(function(){doTravel(destination, from, tab, function(){callback();});},2000);
			}
		});

		function CurrentCity(html) {
			var CityData = html || document.body.innerHTML;
			var CurrentCityr;
			if (/current_city_id'.\s*=\s*parseInt."(\d)".;/i.test(CityData)) {
				CurrentCityr = /current_city_id'.\s*=\s*parseInt."(\d)".;/i.exec(CityData)[1];
			} else {
				CurrentCityr = String($(CityData).find('#mw_city_wrapper').attr('class')).substring(7);
			}
			return (CurrentCityr)
		}
	}
		
	function setCurrentCity(shtml) {
		var usr = User&&User.page ? User : (unsafeWindow||window||{}).User;
		if (!(usr && usr.page)){
		} else {
			if (typeof shtml === 'string') {
				var page_rex = /Page:\s*([a-zA-Z]*)_controller/i;
				if (page_rex .test(shtml)) {
					usr.page = page_rex.exec(shtml)[1];
					$('#inner_page').attr('class', usr.page + '_controller');
				}
			}
		}
		return usr.page;
	}
	
	function AjxRequest(url, handler, errorhandler) {
		if(!Zangano.isRunning){
			return;
		}
		var zserver = /\/\/(.*)\.mafiawars/.exec(document.location.href)[1];
		if(url.indexOf('html_server.php') >= 0){
			url = url.substr(url.indexOf('?')+1);
		}
		if(/use_boost/.test(url)) {
			url = url.replace(/use_boost=1/,'use_boost=0');
		}
		User.clicks++;
		var params = {
			'ajax': 1,
			'liteload': 1,
			'sf_xw_user_id': User.id,
			'sf_xw_sig': local_xw_sig,
			'xw_client_id': 8,
			'skip_req_frame': 1,
			'clicks': User.clicks
		};
		var preurl = '//'+zserver+'.mafiawars.zynga.com/mwfb/remote/html_server.php?';
		function processRequest() {
			$.ajax({
				type: "POST",
				url: preurl+url,
				data: params,
				cache: false,
				success: function (e) {
					if(!Zangano.isRunning){
						return;
					}
					handler(e)
				},
				timeout: 30000,
				error: function (f) {
					if(errorhandler){
						errorhandler(f);
					}else{
						setTimeout(function(){processRequest();},2000);
					}
				}
			});
		}
		processRequest()
	}
	
	function unix_timestamp() {
		return parseInt(new Date().getTime().toString().substring(0, 10));
	}
	
	function update_sig() {
		var params = {
			"cb": userId+unix_timestamp(),
			"xw_client_id": 8,
			"ajax": 1,
			"liteload": 1,
			"sf_xw_sig": local_xw_sig,
			"sf_xw_user_id": userId
		};
		$.ajax({
			type: "POST",
			url: MW_BASE_URL+'/sf_updater.php',
			data: params,
			success: function (response) {
				local_xw_sig = /([a-f0-9]{32})/.exec(response)[1];
			}
		});
	}
	
	function MyLocation(){
		var locationX = /mw_city(\d+)/.exec(document.getElementById('mw_city_wrapper').className)[1]; 
		return locationX;
	}	

	function check_stamina(handler) {
		loggerCentral('Checking stamina...', 'status');
		AjxRequest('xw_controller=propertyV2&xw_action=createData&xw_city=7&tmp=&cb=&xw_person='+User.id.substr(2)+'&mwcom=1&city=7&xw_client_id=8',function(msg){
			try {
				var data = JSON.parse(msg);
				update_game_ui_sp(data);
				var stamavail=data.user_fields.user_stamina;
				var xpneed=data.user_fields.exp_to_next_level;
			} catch(e) {
				loggerCentral('Error parsing JSON, retry in 5s...', 'status');
				setTimeout(check_stamina,5000,handler);
				return;
			}
			var can_restart = true;
			if(stamavail>500){
				can_restart = true;
			} else {
				can_restart = false;
			}
			if (can_restart) {
				handler();
			} else {
				loggerCentral('Not enough stamina/ratio, check your config settings.', 'status');
				arenaRunning = false;
			}
		});
	}	
	
	function checkResources() {
		if(!Zangano.isRunning){
			return;
		}
		isSkillPointsAvaiable = parseInt($('#user_skill').text());
		if($('#ZX_skillSpending').val() != 0 && $('#ZX_spendSkills').val() == 1 && isSkillPointsAvaiable > 0){
			loggerCentral('Applying Skillpoints to '+ZX_skillSpending, 'status');
			setTimeout(function(){applySkillPoints();},1000);
			return;
		}
		CloseDoopidPopup();
		loggerCentral('Checking resources...', 'status')
		AjxRequest('xw_controller=propertyV2&xw_action=createData&xw_city=11&tmp=&cb=&xw_person='+User.id.substr(2)+'&mwcom=1&city=11&xw_client_id=8', function(msg){
			if(!Zangano.isRunning){
				return;
			}
			try {
				var data = JSON.parse(msg);
				Zangano.resourceInfo.currentEnergy = parseInt(data.user_fields.user_energy);
				Zangano.resourceInfo.currentStamina = parseInt(data.user_fields.user_stamina);
				Zangano.resourceInfo.currentExperience = parseInt(data.user_fields.exp_to_next_level);
			} catch(e) {
				loggerCentral('<span class="bad">Error parsing JSON </span>, retry in ', 'timed', 5, checkResources);
				return;
			}
			Zangano.resourceInfo.currentCombinedRatio = (Zangano.resourceInfo.currentExperience/(Zangano.resourceInfo.currentEnergy+Zangano.resourceInfo.currentStamina)).toFixed(3); 
			document.getElementById('user_energy').innerHTML = Zangano.resourceInfo.currentEnergy;
			document.getElementById('user_stamina').innerHTML = Zangano.resourceInfo.currentStamina;
			var can_job = false;
			for(var i = 0; i < Zangano.JobMap.length; i++){
				if(Zangano.JobMap[i].isStam == true && Zangano.resourceInfo.currentStamina >= Zangano.JobMap[i].isCost||Zangano.JobMap[i].isStam == false && Zangano.resourceInfo.currentEnergy >= Zangano.JobMap[i].isCost){
					can_job = true;			
				}
			}
			if(can_job) {
				selectJob();
			} else {
				if($('#ZX_skillSpending').val() != 0 && $('#ZX_spendSkills').val() == 0 && isSkillPointsAvaiable > 0){
					loggerCentral('Applying Skillpoints to '+ZX_skillSpending, 'status');
					setTimeout(function(){applySkillPoints();},1000);
					return;
				}
				if($('#ZX_noResources').val() == 0){
					loggerCentral('Traveling to idle City', 'status');
					doTravel($('#ZX_idleCity').val(), 'job', 1);
					return;
				}else if($('#ZX_noResources').val() == 1){
					var wait = parseInt($('#ZX_restartTime').val()*60*1000);
					loggerCentral('Outta NRG & Stamina restarting in '+$('#ZX_restartTime').val()+' minutes ('+displayTime($('#ZX_restartTime').val())+')', 'status')
					$('#status').append(' <a href="#" id="insta_RS">(Restart Now)</a>');
					ClickGo = setTimeout(function(){checkResources();},wait);
					$('#insta_RS').click(function(){
						clearTimeout(ClickGo);
						loggerCentral('Attempting a restart...', 'status')
						setTimeout(function(){checkResources();},500);				
						return false;
					});
/*					var wait = parseInt($('#ZX_restartTime').val()*60*1000);
					loggerCentral('Outta NRG & Stamina restarting in '+$('#ZX_restartTime').val()+' minutes', 'status')
					setTimeout(function(){checkResources();},wait) */
				}else{
					loggerCentral('<span class="bad">Outta NRG & Stamina</span>', 'status');
					$('#stop').click();
				}
			}
		});
	}		
	
	function selectJob(){
		var i;
		jobArray = new Array();
		selectJobLoop:
		for(i = 0; i < Zangano.JobMap.length; i++){
			var willLevel;
			if(Zangano.JobMap[i].isStam == true && Zangano.resourceInfo.currentStamina >= Zangano.JobMap[i].isCost){
				if(Zangano.JobMap[i].isRobbing){
					break selectJobLoop;
				}else if(Zangano.JobMap[i].isFighting){
					break selectJobLoop;
				}else if(Zangano.JobMap[i].isKami){
					break selectJobLoop;
				}else if(Zangano.JobMap[i].isArena){
					break selectJobLoop;
				}else{
					Zangano.jobInfo.timesToDoJob = parseInt(Math.floor(Zangano.resourceInfo.currentStamina/Zangano.JobMap[i].isCost));
					willLevel = Zangano.jobInfo.timesToDoJob*Zangano.JobMap[i].isExp;
					if(Zangano.resourceInfo.currentExperience - willLevel <= 0){
						Zangano.jobInfo.timesToDoJob = parseInt(Math.ceil(Zangano.resourceInfo.currentExperience/Zangano.JobMap[i].isExp));
					}
					if(Zangano.JobMap[i].RatioSwitchingOn){
						if(i != Zangano.JobMap.length-1){
							if(Zangano.JobMap[i+1].isStam == true && Zangano.resourceInfo.currentStamina >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentCombinedRatio <= Zangano.JobMap[i].RatioSwitchVal){
								continue selectJobLoop;
							}else if(Zangano.resourceInfo.currentEnergy >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentCombinedRatio <= Zangano.JobMap[i].RatioSwitchVal){
								continue selectJobLoop;
							}
							Zangano.jobInfo.SwitchRatio = Zangano.JobMap[i].RatioSwitchVal;
							var changeTime = parseInt(ratioPredict0rStamina(Zangano.JobMap[i].isCost, Zangano.JobMap[i].isExp));
							if(changeTime < Zangano.jobInfo.timesToDoJob){
								Zangano.jobInfo.timesToDoJob = changeTime;
								loggerCentral('Ratio predicted to change if job is done: x'+Zangano.jobInfo.timesToDoJob, 'log');
							}
							if(Zangano.jobInfo.timesToDoJob < 1){
								Zangano.jobInfo.timesToDoJob = 1;
							}
							break selectJobLoop;
						}else{
							break selectJobLoop;
						}
					}else if(Zangano.JobMap[i].ResourceSwitchingOn){
						if(i != Zangano.JobMap.length-1){
							if(Zangano.JobMap[i+1].isStam == true && Zangano.resourceInfo.currentStamina >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentStamina <= Zangano.JobMap[i].ResourceSwitchVal){
								continue selectJobLoop;
							}else if(Zangano.resourceInfo.currentEnergy >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentEnergy <= Zangano.JobMap[i].ResourceSwitchVal){
								continue selectJobLoop;
							}
							Zangano.jobInfo.SwitchAmount = Zangano.JobMap[i].ResourceSwitchVal;
							var changeTime = parseInt(staminaPredict0r(Zangano.JobMap[i].isCost));
							if(changeTime < Zangano.jobInfo.timesToDoJob){
								Zangano.jobInfo.timesToDoJob = changeTime;
								loggerCentral('Stamina will be less than switch amount, if job is done: x'+Zangano.jobInfo.timesToDoJob, 'log');
							}
							if(Zangano.jobInfo.timesToDoJob < 1){
								Zangano.jobInfo.timesToDoJob = 1;
							}
							break selectJobLoop;
						}else{
							break selectJobLoop;
						}
					}else{
						break selectJobLoop;
					}
				}
			}else if(Zangano.JobMap[i].isStam == false && Zangano.resourceInfo.currentEnergy >= Zangano.JobMap[i].isCost){
	/*			if(i != 0 && Zangano.resourceInfo.currentCombinedRatio > Zangano.JobMap[i].isRatio && Zangano.resourceInfo.currentEnergy >= Zangano.JobMap[i-1].isCost){
					backtrack = true;
					i = i-1;
				}*/
				Zangano.jobInfo.timesToDoJob = parseInt(Math.floor(Zangano.resourceInfo.currentEnergy/Zangano.JobMap[i].isCost));
				willLevel = Zangano.jobInfo.timesToDoJob*Zangano.JobMap[i].isExp;
				if(Zangano.resourceInfo.currentExperience - willLevel <= 0){
					Zangano.jobInfo.timesToDoJob = parseInt(Math.ceil(Zangano.resourceInfo.currentExperience/Zangano.JobMap[i].isExp));
			//		logit('times to do job XX: '+Zangano.jobInfo.timesToDoJob)
				}
/*				if(backtrack){
					break selectJobLoop;
				}*/
				if(Zangano.JobMap[i].RatioSwitchingOn){
					if(i != Zangano.JobMap.length-1){
						if(Zangano.JobMap[i+1].isStam == true && Zangano.resourceInfo.currentStamina >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentCombinedRatio <= Zangano.JobMap[i].RatioSwitchVal){
							continue selectJobLoop;
						}else if(Zangano.resourceInfo.currentEnergy >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentCombinedRatio <= Zangano.JobMap[i].RatioSwitchVal){
							continue selectJobLoop;
						}
						Zangano.jobInfo.SwitchRatio = Zangano.JobMap[i].RatioSwitchVal;
						var changeTime = parseInt(ratioPredict0rEnergy(Zangano.JobMap[i].isCost, Zangano.JobMap[i].isExp));
						if(changeTime < Zangano.jobInfo.timesToDoJob){
							Zangano.jobInfo.timesToDoJob = changeTime;
							loggerCentral('Ratio predicted to change if job is done: x'+Zangano.jobInfo.timesToDoJob, 'log');
						}
						if(Zangano.jobInfo.timesToDoJob < 1){
							Zangano.jobInfo.timesToDoJob = 1;
						}
						break selectJobLoop;
					}else{
						break selectJobLoop;
					}
				}else if(Zangano.JobMap[i].ResourceSwitchingOn){
					if(i != Zangano.JobMap.length-1){
						if(Zangano.JobMap[i+1].isStam == true && Zangano.resourceInfo.currentStamina >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentStamina <= Zangano.JobMap[i].ResourceSwitchVal){
							continue selectJobLoop;
						}else if(Zangano.resourceInfo.currentEnergy >= Zangano.JobMap[i+1].isCost && Zangano.resourceInfo.currentEnergy <= Zangano.JobMap[i].ResourceSwitchVal){
							continue selectJobLoop;
						}
						Zangano.jobInfo.SwitchAmount = Zangano.JobMap[i].ResourceSwitchVal;
						var changeTime = parseInt(energyPredict0r(Zangano.JobMap[i].isCost));
						if(changeTime < Zangano.jobInfo.timesToDoJob){
							Zangano.jobInfo.timesToDoJob = changeTime;
							loggerCentral('Energy will be less than switch amount, if job is done: x'+Zangano.jobInfo.timesToDoJob, 'log');
						}
						if(Zangano.jobInfo.timesToDoJob < 1){
							Zangano.jobInfo.timesToDoJob = 2;
						}
						break selectJobLoop;
					}else{
						break selectJobLoop;
					}
				}else{
					break selectJobLoop;
				}
			}
		}
		jobArray[0] = Zangano.JobMap[i];
		$('#inAction').html(jobArray[0].isName);
		loggerCentral('Going to '+jobArray[0].isName+' Doing job x'+Zangano.jobInfo.timesToDoJob, 'debug');
		if(jobArray[0].isArena){
			startSpart();
			return;
		}		
		if(jobArray[0].isRobbing){
			doTravel(jobArray[0].isCity, 'robbing', 'robbing', function(){smartRob();})
			return;
		}
		if(jobArray[0].isFighting||jobArray[0].isKami){
			doTravel(jobArray[0].isCity, 'fight', 1, function(){start_fighting();})
			return;
		}else{ 
			Zangano.jobInfo.timesJobDone = 1;
			var JobToClick;
			if(jobArray[0].isCity > 1) {
				JobToClick = $('#btn_dojob_'+jobArray[0].isID).get(0);
			}else{
				JobToClick = $('#city_job_'+ jobArray[0].isID +' > .job_action > a').get(0);
			}
			if(JobToClick && MyLocation() == jobArray[0].isCity){
				loggerCentral('Quick switch, no traveling required!', 'status')
				setTimeout(function(){jobChecker();},1000);
			}else{
				doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})
			}
		}
	}
	
	function energyPredict0r(isCost){
		var i;
		for(i = 1; i < Math.floor(Zangano.resourceInfo.currentEnergy/parseInt(isCost)); i++){
			var futureEnergy = Zangano.resourceInfo.currentEnergy - (parseInt(isCost)*i)
			if(futureEnergy <= Zangano.jobInfo.SwitchAmount && futureEnergy > parseInt(isCost)){
				return 1*i;
			}
		}
	}	
	
	function staminaPredict0r(isCost){
		var i;
		for(i = 1; i < Math.floor(Zangano.resourceInfo.currentStamina/parseInt(isCost)); i++){
			var futureStamina = Zangano.resourceInfo.currentStamina - (parseInt(isCost)*i)
			if(futureStamina <= Zangano.jobInfo.SwitchAmount && futureStamina > parseInt(isCost)){
				return 1*i;
			}
		}
	}

	function ratioPredict0rEnergy(isCost, isExp){
		var i;
		if(Math.floor(Zangano.resourceInfo.currentEnergy/parseInt(isCost)) == 1){
			return 1;
		}else{
			for(i = 1; i < Math.floor(Zangano.resourceInfo.currentEnergy/parseInt(isCost)); i++){
				var futureExp = Zangano.resourceInfo.currentExperience - (parseInt(isExp)*i)
				var futureEnergy = Zangano.resourceInfo.currentEnergy - (parseInt(isCost)*i)
				var futureRatio = (futureExp/(futureEnergy+Zangano.resourceInfo.currentStamina)).toFixed(3);
				if(futureRatio <= Zangano.jobInfo.SwitchRatio && futureEnergy >= parseInt(isCost)){
					return 1*i;
				}
			}
		}
		return i;
	}	
	
	function ratioPredict0rStamina(isCost, isExp){
		var i;
		if(Math.floor(Zangano.resourceInfo.currentStamina/parseInt(isCost)) == 1){
			return 1;
		}else{
			for(i = 1; i < Math.floor(Zangano.resourceInfo.currentStamina/parseInt(isCost)); i++){
				var futureExp = Zangano.resourceInfo.currentExperience - (parseInt(isExp)*i)
				var futureStamina = Zangano.resourceInfo.currentStamina - (parseInt(isCost)*i)
				var futureRatio = (futureExp/(futureStamina+Zangano.resourceInfo.currentEnergy)).toFixed(3);
				if(futureRatio <= Zangano.jobInfo.SwitchRatio && futureStamina >= parseInt(isCost)){
					return 1*i;
				}
			}
		}
		return i;
	}
	
	function jobChecker(){
		if(!Zangano.isRunning){
			return;
		}
		CloseDoopidPopup();
		if(Zangano.jobInfo.timesJobDone > Zangano.jobInfo.timesToDoJob){
	//	loggerCentral('done is x'+Zangano.jobInfo.timesJobDone+' todo is x'+Zangano.jobInfo.timesToDoJob,'debug')
			if($('#ZX_bankAbove').val() > 9){
				UpdateCashInHand();
				if (cash_in_hand > 10) {
					if($('#ZX_disableNY').is(':checked') && MyLocation() == 1){
						//banking disabled in NY
					}else{
						setTimeout(function (){banker();},100);
						return;
					}
				}else{
//					loggerCentral(timestamp()+'<span class="bad">You need to deposit at least $10!</span>', 'log');
				}
			}
			setTimeout(function (){checkResources();},1000);
		}else{
			if (/These loot drops are needed for this job/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Not enough consumables..</span>', 'log');
				$('#stop').click();
				return;
			}
			if (/You do not have enough cash to do this job/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Not enough cash..</span>', 'log');
				$('#stop').click();
				return;		
			}
			if (/There are no secret districts currently open!/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Secret District Appears to of gone walkies..</span>', 'log');
				$('#stop').click();
				return;		
			}
			if (/- Locked/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Secret District Not unlocked!</span>', 'log');
				$('#stop').click();
				return;		
			}
			if (/MW: This link has expired. Please reload./.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Session expired..</span>', 'log');
				$('#stop').click();
				return;
			}
			if (/Your session has timed out. Click any button to resume playing./.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Session expired..</span>', 'log');
				$('#stop').click();
				return;
			}		
			if (/You do not have enough/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Zynga Click Jam in place, Traveling..</span>', 'log');
				setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
				return;
			}
			if (/You need .* Energy/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Zynga Click Jam in place, Traveling..</span>', 'log');
				setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
				return;
			}
			if (/You need .* Stamina/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Zynga Click Jam in place, Traveling..</span>', 'log');
				setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
				return;
			}
			if (/ERROR 500: response never closed/.test(document.body.innerHTML)) {
				loggerCentral('<span class="bad">Zynga server fail, Traveling..</span>', 'log');
				setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
				return;
			}			
			
			var onMarketPlace = document.evaluate('//div[contains(@class, "marketplace_controller")]//a[contains(., "ALL ITEMS")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength > 0;
			if(onMarketPlace > 0){
				loggerCentral('<span class="bad">Marketplace Tab, Why i go here..</span>', 'log');
				return;
			}
			try {
				if(jobArray[0].isCity == 11 && jobArray[0].isTab < 13) {
					var checkEnergyLog = '';
					var checkEnergySaved = jobArray[0].isCost; 
					var checkEnergyOnscreen = parseInt($('#job-id-'+jobArray[0].isID).find('.energy:last').attr('current_value')) || 0; 
					var checkStaminaOnscreen = parseInt($('#job-id-'+jobArray[0].isID).find('.stamina:last').attr('current_value')) || 0; 
					var checkExperienceOnscreen = parseInt($('#job-id-'+jobArray[0].isID).find('.experience:last').attr('current_value'));
					if(checkEnergyOnscreen == 0 && checkStaminaOnscreen == 0){
						logit('chk nrg is: '+checkEnergyOnscreen + 'chk stam is: '+checkStaminaOnscreen+' id is:'+jobArray[0].isID)
						if(mexicoResourceError > 3){
							loggerCentral('Error: Mexico Pageload issue, trying a different approach...', 'debug');
							doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})
							//setTimeout(function (){checkResources();},1000);
							return;
						}
						mexicoResourceError++
						loggerCentral('Error: Energy/Stamina not displaying onscreen correctly...', 'debug');
						setTimeout(jobChecker, 500);
						return;
					}
					mexicoResourceError = 0;
					var resourcePool = (checkEnergyOnscreen > 0 ? checkEnergyOnscreen : checkStaminaOnscreen);
					//add mex boss detection code here for future usage..
					//set mex boss as active in script
					//var isBoss = $('#boss-district-job-top-hud').find('.timer-cont').text();
					//if(isBoss.indexOf('active') > -1){alert('is active')}else{alert('not active')}
					var isBoss = $('#boss-district-job-top-hud').find('.details').text();
					if(isBoss.indexOf('RECRUITED') > -1){
//						alert('is recruited')
					} else if(isBoss.indexOf('INACTIVE') > -1){
//						alert('not active')
					}else if(isBoss.indexOf('ACTIVE') > -1){
//						alert('is active')
						if($('#ZX_mexBossActive').is(':checked')){
							loggerCentral('<span class="bad">Mexican Boss Detected, Stopping...</span>', 'status');
							$('#stop').click();
							return;
						}
					}
					if (checkEnergySaved != resourcePool && !isNaN(checkExperienceOnscreen)) {
						jobArray[0].isCost = Zangano.JobMap[jobArray[0].ArrayIndex].isCost = resourcePool
						jobArray[0].isExp = Zangano.JobMap[jobArray[0].ArrayIndex].isExp = checkExperienceOnscreen
						jobArray[0].isRatio = Zangano.JobMap[jobArray[0].ArrayIndex].isRatio = parseFloat(jobArray[0].isExp/jobArray[0].isCost).toFixed(3);
						checkEnergyLog = 'Learnt new energy cost, Energy cost per job is now ' + jobArray[0].isCost + ' & XP Payout is ' + jobArray[0].isExp + ' ratio for job is now '+jobArray[0].isRatio;
						loggerCentral(checkEnergyLog, 'log');
						setTimeout(function (){checkResources();},500);
						return;
					}
				}
			} catch (err) {}
			if($('#job-id-'+jobArray[0].isID).find('.bandit-wrapper').length > 0){
				Zangano.banditInfo.crewMembers = parseInt(document.getElementById('btn_queue').childNodes[0].childNodes[0].childNodes[2].innerHTML);
				Zangano.banditInfo.banditsActive = true;
				Zangano.banditInfo.Bandit_type = $('#job-id-'+jobArray[0].isID).find('.bandit-desc').text();
				Zangano.banditInfo.Bandit_elim = $('#job-id-'+jobArray[0].isID).find('.bandit-eliminate-btn > a').attr('href');
				Zangano.banditInfo.Bandit_timer = $('#job-id-'+jobArray[0].isID).find('.bandit-timer').text();
				Zangano.banditInfo.testBanditTimer = parseInt(Zangano.banditInfo.Bandit_timer);
				if(isNaN(Zangano.banditInfo.testBanditTimer)){
					Zangano.banditInfo.Bandit_timer = 'Not detected';
					Zangano.banditInfo.testBanditTimer = parseInt(Zangano.banditInfo.backUpBanditTimer);
				}else{
					Zangano.banditInfo.backUpBanditTimer = Zangano.banditInfo.Bandit_timer;
				}
				if (Zangano.banditInfo.crewMembers == 0) {
					loggerCentral('<span class="bad">Not Killing '+Zangano.banditInfo.Bandit_type+'... Because no Crew!</span>', 'log');
					loggerCentral('<span class="good">Waiting out '+Bandit_type+'.. Restarting in </span>', 'timed', 5*60, doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();}))
					return;
				}
			}else{
				Zangano.banditInfo.banditsActive = false;
			}
			Zangano.jobInfo.timesJobDone++;
			Zangano.resourceInfo.currentEnergy = parseInt(document.getElementById('user_energy').innerHTML);
			if(jobArray[0].isStam){
				if(Zangano.resourceInfo.currentStamina < jobArray[0].isCost){ 
					Zangano.jobInfo.timesJobDone = Zangano.jobInfo.timesToDoJob+1;
					setTimeout(function (){jobChecker();},100);
					return;
				}else if(Zangano.resourceInfo.currentEnergy == 0){
					loggerCentral('Waiting for 1 energy so we can do a stamina requiring job', 'status');
					setTimeout(function(){jobChecker();},1000*60);
					return;
				}
			}else{
				if(Zangano.resourceInfo.currentEnergy < jobArray[0].isCost){ 
					Zangano.jobInfo.timesJobDone = Zangano.jobInfo.timesToDoJob+1;
					if($('#job-id-'+jobArray[0].isID).find('.bandit-wrapper').length > 0 && Zangano.banditInfo.Bandit_type == "XP Bandit" && Zangano.banditInfo.crewMembers > 0){
						AjxRequest(Zangano.banditInfo.Bandit_elim, function (response){
							setTimeout(function (){jobChecker();},500);
						});
						return;
					}else{
						setTimeout(function (){jobChecker();},100);
						return;
					}
				}
			}
			if(Zangano.banditInfo.banditsActive){
				if(Zangano.banditInfo.Bandit_type == "Job Bandit"){
					if(document.getElementById("JOBBanO").selectedIndex < 1){
						loggerCentral('<span class="bad">Attempting to Kill '+Zangano.banditInfo.Bandit_type+'...</span>', 'status');
						AjxRequest(Zangano.banditInfo.Bandit_elim, function (response){
							setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
						});
						return;
					}else{
						loggerCentral('<span class="bad">Not Killing '+Zangano.banditInfo.Bandit_type+'... </span>', 'status');
						setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();});},60*1000*5);
						return;
					}
				}else if(Zangano.banditInfo.Bandit_type == "Cash Bandit"){
					if(document.getElementById("CSHBanO").selectedIndex == 1){
						setTimeout(function(){jobClicker();},100);
						return;
					}
					if(document.getElementById("CSHBanO").selectedIndex < 2 || Zangano.banditInfo.testBanditTimer <= Zangano.Saving.BanditElapsedTimerCash) {
						loggerCentral('<span class="bad">Attempting to Kill '+Zangano.banditInfo.Bandit_type+'...</span>', 'status');
						AjxRequest(Zangano.banditInfo.Bandit_elim, function (response){
							setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
						});
						return;
					}
				}else if(Zangano.banditInfo.Bandit_type == "XP Bandit"){
					if(document.getElementById("XPBanO").selectedIndex < 1 || Zangano.banditInfo.testBanditTimer <= Zangano.Saving.BanditElapsedTimerXP) {
						loggerCentral('<span class="bad">Attempting to Kill '+Zangano.banditInfo.Bandit_type+'...</span>', 'status');
						AjxRequest(Zangano.banditInfo.Bandit_elim, function (response){
							setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
						});
						return;
					}else{
						setTimeout(function(){jobClicker();},100);
						return;
					}
				}
			}else{
				loggerCentral('Doing Job...', 'status');
				loggerCentral('Doing Job...', 'log');
				setTimeout(function(){jobClicker();},50);
			}
		}
	}
	
	function jobClicker(){
		if(!Zangano.isRunning){
			return;
		}
		CloseDoopidPopup();
		var jobToClick;
		if(jobArray[0].isCity > 1) {
			JobToClick = $('#btn_dojob_'+jobArray[0].isID).get(0);
		}else{
			JobToClick = $('#city_job_'+ jobArray[0].isID +' > .job_action > a').get(0);
		}
		if(JobToClick){
			updateStats('JobCounter_'+jobArray[0].isID);
			if(jobArray[0].isCity == MyLocation()){
				if(jobArray[0].isCity == 1){
					$('#city_job_' + jobArray[0].isID + ' > .job_action > a').click();
				}else{
					$('#btn_dojob_' +jobArray[0].isID).click();
				}
				setTimeout(function(){jobChecker();},Zangano.Saving.jobSpeed);
			}
		}else{
			loggerCentral('button not detected, traveling..', 'debug');
			Zangano.jobInfo.timesJobDone--;
			doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();});
		}
	}
	
	function smartRob(){
		var already_robbed = 0;
		var _slots = new Array();
		var er500 = false;
		var slotsToSend = 0;
		var slotsRecieved = 0;
		var actualLevel = $('#user_level').text();
		var CurrentSTAM = parseInt(document.getElementById('user_stamina').innerHTML);
		if(actualLevel != Zangano.CurrentLevel){
			CloseDoopidPopup();
			setTimeout(function (){checkResources();},1000);
			return;
		}
		if(chkresources){
			chkresources = false;
			setTimeout(function (){checkResources();},1000);
			return;
		}
		if (/ERROR 500: response never closed/.test(document.body.innerHTML)) {
			loggerCentral('<span class="bad">Zynga server fail, Traveling..</span>', 'log');
			setTimeout(function (){doTravel(jobArray[0].isCity, 'job', jobArray[0].isTab, function(){jobChecker();})},500);
			return;
		}
		$('.rob_slot').each(function(indexofthis){
			if($(this).find('.rob_prop_stamina').length > 0){
				_slots[indexofthis] = {
					robbed: false,
					cost: parseInt($(this).find('.rob_prop_stamina').text())
				};
			}else{
				_slots[indexofthis] = {
					robbed: true
				};
				already_robbed++
			}
		})
			
		function doRobbieries(){
			for(var i = 0; i < 9; i++){
				if(_slots[i].robbed === false){
					if(CurrentSTAM >= _slots[i].cost){
						loggerCentral('Robbing..', 'status');
						loggerCentral('doing robbing for slot: '+i, 'log');
						slotsToSend++;
						AjxRequest('remote/html_server.php?xw_controller=robbing&xw_action=rob&xw_city=1&slot='+i, function(msg){
							slotsRecieved++;
							if (msg.indexOf('ERROR 500: response never closed')!=-1) {
								er500 = true;
							}else{
								_slots[/slot_id":(\d+)/.exec(msg)[1]] = {
									robbed: true
								};
								var data = JSON.parse(msg);
								CurrentSTAM = parseInt(data.user_fields.user_stamina);
								if(msg.indexOf('You are now LEVEL')!=-1) {
									chkresources = true;
									loggerCentral('Levelup!','status');
									grab_bonus();
								}
								if(/refresh_cost":(\d+)/.exec(msg)[1] == 0){
									loggerCentral('refreshing board...', 'log')
									AjxRequest('remote/html_server.php?xw_controller=robbing&xw_action=refresh', function(msg){
										doTravel(jobArray[0].isCity, 'robbing', 'robbing', function(){smartRob();})
									});
									return;
								} 
							}
							if(i == 9 && er500 == true && slotsToSend == slotsRecieved){
								loggerCentral('er500 resending a req', 'log');
								er500 = false;
								setTimeout(function (){doRobbieries();},100);
								return;
							}
						});
					}else if(CurrentSTAM < _slots[i].cost){//not enough stamina
						setTimeout(function (){checkResources();},1000);
						return;
					}
				}
			}
		}
		if(already_robbed < 8){
			doRobbieries();
		}else{
			AjxRequest('remote/html_server.php?xw_controller=robbing&xw_action=refresh', function(msg){
				doTravel(jobArray[0].isCity, 'robbing', 'robbing', function(){smartRob();})
			});
		}
	}

	function applySkillPoints(){
		var url;
		var SkillPointNum;
		if(isSkillPointsAvaiable >= 5 && isSkillPointsAvaiable < 25){
			url = 'xw_controller=stats&xw_action=upgrade&xw_city=11&upgrade_key='+SkillToSpend+'&upgrade_amt=5&no_load=1&source=level_up_popup';
		}else if(isSkillPointsAvaiable >= 25 && isSkillPointsAvaiable < 100){
			url = 'xw_controller=stats&xw_action=upgrade&xw_city=11&upgrade_key='+SkillToSpend+'&upgrade_amt=25&no_load=1&source=level_up_popup';
		}else if(isSkillPointsAvaiable >= 100){
			url = 'xw_controller=stats&xw_action=upgrade&xw_city=11&upgrade_key='+SkillToSpend+'&upgrade_amt=100&no_load=1&source=level_up_popup';
		}else{
			url = 'xw_controller=stats&xw_action=upgrade&xw_city=11&upgrade_key='+SkillToSpend+'&upgrade_amt=1&no_load=1&source=level_up_popup';
		}
		if(url.match(/&upgrade_amt=5/g)){
			SkillPointNum = '5 Skillpoints';
		}else if(url.match(/&upgrade_amt=25/g)){
			SkillPointNum = '25 Skillpoints';
		}else if(url.match(/&upgrade_amt=100/g)){
			SkillPointNum = '100 Skillpoints';
		}else if(url.match(/&upgrade_amt=1&/g)){
			SkillPointNum = '1 Skillpoint';
		}		
		AjxRequest(url,function(msg){
			try{
				var data = JSON.parse(msg);
				user_fields_update(data.user_fields);
				user_info_update(data.user_fields, data.user_info);
				isSkillPointsAvaiable = parseInt(data.user_fields.user_skill);
				if(isSkillPointsAvaiable == 0){
					loggerCentral('All Skillpoints Applied!', 'status')
					setTimeout(function (){checkResources();},1000);
				}else{
					loggerCentral('<span class="good">Applied <font color="gold">'+SkillPointNum+'</font> to:</span> <font color="gold">'+SkillsTo+'</font>', 'status');
					setTimeout(function (){applySkillPoints();},1000);
				}
			}catch(errz){
				loggerCentral('Failed Applying Skillpoints! Retrying in 5 Seconds...', 'status')
				setTimeout(function (){applySkillPoints();},5000);
			}
		});
	}

	function UpdateCashInHand(){
		cash_in_hand = User.cash;
		/*switch (parseInt(MyLocation())) {
			case 1:
				cash_in_hand = document.getElementById('user_cash_nyc').innerHTML.replace(/,/g, '').replace(/\$/g, '');
				break;
			case 2:
				cash_in_hand = document.getElementById('user_cash_cuba').innerHTML.replace(/,/g, '').replace(/C\$/g, '');
				break;
			case 3:
				cash_in_hand = document.getElementById('user_cash_moscow').innerHTML.replace(/,/g, '').replace(/R\$/g, '');
				break;
			case 4:
				cash_in_hand = document.getElementById('user_cash_bangkok').innerHTML.replace(/,/g, '').replace(/B\$/g, '');
				break;
			case 5:
				cash_in_hand = document.getElementById('user_cash_vegas').innerHTML.replace(/,/g, '').replace(/V\$/g, '');
				break;
			case 6:
				cash_in_hand = document.getElementById('user_cash_italy').innerHTML.replace(/,/g, '').replace(/L\$/g, '');
				break;
			case 7:
				cash_in_hand = document.getElementById('user_cash_brazil').innerHTML.replace(/,/g, '').replace(/BRL\$/g, '');
				break
			case 8:
				cash_in_hand = document.getElementById('user_cash_chicago').innerHTML.replace(/,/g, '').substring(1);
				break
			case 9:
				cash_in_hand = document.getElementById('user_cash_london').innerHTML.replace(/,/g, '').substring(1);
				break
			case 10:
				cash_in_hand = document.getElementById('user_cash_southafrica').innerHTML.replace(/,/g, '').substring(1);
				break
			case 11:
				cash_in_hand = document.getElementById('user_cash_mexico').innerHTML.replace(/,/g, '').substring(1);
				break	
		}*/
	}
	
	function noimg(data) {
		return data.replace(/<img/g,'<noimg');
	}

	function banker() {
		if(!Zangano.isRunning){
			return;
		}
		var cb = userId+unix_timestamp();
		User.clicks++;
		var params = {
			'ajax': 1,
			'sf_xw_user_id': User.id,
			'sf_xw_sig': local_xw_sig,
			'liteload': 1,
			'cb': cb,
			'xw_client_id': 8,
			'skip_req_frame': 1,
			'amount': cash_in_hand,
			'xw_city': MyLocation(),
			'xw_person': User.id.substr(2),
			'clicks': User.clicks
		};
		if ((MyLocation() == 10) && $('#ZX_buyCityStore').is(':checked')) {
			loggerCentral('attempting to buy citystore items...','status');
			var num = parseInt(Math.floor(cash_in_hand / 135));
			if(num == 0){
				loggerCentral('not enough cash to buy citystore items','log');
				setTimeout(function (){checkResources();},100);
				return;
			}
			var numafter = parseInt(num * 135);
			AjxRequest('xw_controller=item&xw_action=view&xw_city=10&xw_person='+User.id+'&mwcom=1&tab=5',function(msg) {
				$msg=$(noimg(msg));
				var url=$msg.find('#itemBuy_24882').attr('action');
				var params= {
					'ajax':1,
					'numBuy':num,
					'item':24882,
					'tab':5,
					'sf_xw_user_id':User.id,
					'sf_xw_sig':local_xw_sig 	
				};
				$.ajax({
					type:"POST",
					url:url,
					data:params,
					success: function (buyresponse) {
						loggerCentral($(noimg(buyresponse)).find('.message_body >div:first').text(),'log');
						User.cash-=numafter;
						$('#stat_cash_cont').find('strong[id^="user_cash_"]').text(User.cash)
						setTimeout(function(){jobChecker();},100);
					},
					error: function() { 
						setTimeout(function(){jobChecker();},100);
					}
				});
			});
			return;
		}
		if ((MyLocation() == 11) && $('#ZX_buyCityStore').is(':checked')) {
			loggerCentral('attempting to buy citystore items...','status');
			var num=parseInt(Math.floor(cash_in_hand / 108));
			if(num == 0){
				loggerCentral('not enough cash to buy citystore items','log');
				setTimeout(function (){checkResources();},1000);
				return;
			}
			var numafter = parseInt(num * 108);
			AjxRequest('xw_controller=item&xw_action=view&xw_city=11&xw_person='+User.id+'&mwcom=1&tab=5',function(msg) {
				$msg=$(noimg(msg));
				var url=$msg.find('#itemBuy_27296').attr('action');
				var params= {
					'ajax':1,
					'numBuy':num,
					'item':27296,
					'tab':5,
					'sf_xw_user_id':User.id,
					'sf_xw_sig':local_xw_sig 	
				};
				$.ajax({
					type:"POST",
					url:url,
					data:params,
					success: function (buyresponse) {
						loggerCentral($(noimg(buyresponse)).find('.message_body >div:first').text(),'log');
						User.cash-=numafter;
						$('#stat_cash_cont').find('strong[id^="user_cash_"]').text(User.cash)
						setTimeout(function(){jobChecker();},100);
					},
					error: function() {
						setTimeout(function(){jobChecker();},100); 
					}
				});
			});
			return;
		}
		else {
			var url = MW_BASE_URL+'/remote/html_server.php?xw_controller=bank&xw_action=deposit'+($('#ZX_disableNY').is(':checked')?'_all':'');
		}
		$.ajax({
			type: "POST",
			url: url,
			data: params,
			success: function (bankresponse) {
				var bankobject = jQuery.parseJSON(bankresponse.replace(/^(\s\d\s+)/,''));
				var message = '';
				try {
					update_game_ui(bankobject);
				}
				catch (banker_user_fields) {
				}
				if (Util.isset(bankobject.deposit_message)) {
					if (/bank can only hold/.test(bankobject.deposit_message)) {
						//New York bank is full
						loggerCentral(bankobject.deposit_message,'log');
						if(!$('#ZX_buyCityStore').is(':checked')){
							loggerCentral('Bank is full, turning on citystore buying...', 'log');
							$('#ZX_buyCityStore').prop('checked', true);
						}
					}
					else {
						var banked = $(bankobject.deposit_message).find('span.money:last').html() || '';
						var money = parseInt(banked.replace(/[^0-9]/g, ''));
						var message = bankobject.deposit_message+' <span class="more_in">(Balance: '+bankobject.bank_balance+')</span>';
						loggerCentral(message,'log');
					}
				}
				if (Util.isset(bankobject.success_message)) {
					if (/You cannot deposit any more/.test(bankobject.success_message)) {
						// Vault full = 'You cannot deposit any more'
						if(!$('#ZX_buyCityStore').is(':checked')){
							$('#ZX_buyCityStore').prop('checked', true);
						}
					}
					loggerCentral(bankobject.success_message,'log');
				}
				setTimeout(function(){jobChecker();},100);
			},
			error: function() { 
				setTimeout(function(){jobChecker();},100); 
			}
		});
	}	
	
	function update_game_ui(object) {
		if (Util.isset(object.user_fields)) {
			user_fields_update(object.user_fields);
			user_info_update(object.user_fields, object.user_info);
		}
		if (Util.isset(object.questData)) {
			MW.QuestBar.update(object.questData);
		}
	}
	
	function timedMessage(seconds,message,resume_func) {
		var delay = (seconds > 0)? delay = 1000 : delay = 100;
		var minutes = (parseInt(seconds/60) == 1) ? 0 : parseInt(seconds/60);
		if (minutes > 0) {
			loggerCentral(message+' <span id="minutes">'+minutes+' minute'+(minutes==1?'':'s')+'</span> <span id="seconds">'+(seconds%60)+' second'+(seconds==1?'':'s')+'</span>...', 'status');
		}
		else {
			loggerCentral(message+' <span id="minutes"></span><span id="seconds">'+(seconds%60)+' second'+(seconds==1?'':'s')+'</span>...', 'status');
		}
		messageTimer = setInterval(function(){
			if (seconds%60 == 0) {
				minutes--;
			}
			seconds--;
			if (document.getElementById('minutes')) {
				document.getElementById('minutes').innerHTML = (minutes > 0) ? minutes+' minute'+(minutes==1?'':'s') : '';
			}
			if (document.getElementById('seconds')) {
				document.getElementById('seconds').innerHTML = (seconds % 60)+' second'+(seconds==1 ? '' : 's');
			}
			else {
				clearInterval(messageTimer);
			}
			if (seconds <= 0) {
				clearInterval(messageTimer);
				if (typeof resume_func == 'function') {
					resume_func();
				}
			}
		},delay);
	}
	
	function loggerCentral(msg, whichLog, timeIs, gotoFunc) {
		if(debug){
			loggerCentral(msg, 'debug'); 
		}
		if(whichLog == 'status'){
			$('#status').html(msg);
		}else if(whichLog == 'timed'){
			timedMessage(timeIs, msg, gotoFunc)
		}else if(whichLog == 'log'){
			DroneLog.unshift(timestamp()+msg);
			var LogCount = DroneLog.length;
			var limit = parseInt($('#log_size').val());
			DroneLog.length = (LogCount < limit) ? LogCount: limit;
			document.getElementById('log').innerHTML = '';
			var LogEntry = '';
			for (LogCount = 0; LogCount < DroneLog.length; LogCount++) {
				LogEntry += DroneLog[LogCount] + '<br>'
			}
			$('#log').html(LogEntry);
		}else if(whichLog == 'debug'){
			setTimeout(function() {
				throw new Error(msg);
			}, 0);
		}
	}

	function timestamp(sec) {
		/*if(seconds is turned on){ //force seconds to appear
			sec = true;
		}*/
		var now = new Date();
		var CurH = now.getHours();
		CurH = (CurH<10?'0'+CurH:CurH);
		var CurM = now.getMinutes();
		CurM = (CurM<10?'0'+CurM:CurM);
		var CurS = now.getSeconds();
		CurS = (CurS<10?'0'+CurS:CurS);
		if(sec =='true') {
			return '<span class="more_in">['+CurH+':'+CurM+':'+CurS+']</span> ';
		} else {
			return '<span class="more_in">['+CurH+':'+CurM+']</span> ';
		}
	}

	
	function displayTime(extra) {
		var addTime = parseInt(extra);
		var str = "";

		var currentTime = new Date()
		var hours = currentTime.getHours()
		var minutes = currentTime.getMinutes()
		var seconds = currentTime.getSeconds()
		
		minutes = minutes+addTime;
		
		if (minutes < 10) {
			minutes = "0" + minutes
		}
		if(minutes > 59){
			minutes = 60 - minutes;
			minutes = "0" + Math.abs(minutes);
			hours = hours+1;
		}
		if (seconds < 10) {
			seconds = "0" + seconds
		}
		str += hours + ":" + minutes + ":" + seconds + " ";
		if(hours > 11){
			str += "PM"
		} else {
			str += "AM"
		}
		return str;
	}
	
	refreshSigTimer = setInterval(update_sig, 300000);
	//clearInterval(refreshSigTimer);
	
	function update_user_scores() {
		try{
			var attack_change = parseInt(parseInt(Zangano.userStats.group_atk) - parseInt(Zangano.userStats.start_group_atk));
			var ac_elt = document.getElementById('DX_atk_inc');
			if (attack_change >= 0) {
				ac_elt.innerHTML = '+' + attack_change;
				ac_elt.className = 'good';
			} else if (attack_change < 0) {
				ac_elt.innerHTML = attack_change;
				ac_elt.className = 'bad';
			}
			var defense_change = parseInt(parseInt(Zangano.userStats.group_def) - parseInt(Zangano.userStats.start_group_def));
			var dc_elt = document.getElementById('DX_def_inc');
			if (defense_change >= 0) {
				dc_elt.innerHTML = '+' + defense_change;
				dc_elt.className = 'good';
			} else if (defense_change < 0) {
				dc_elt.innerHTML = defense_change;
				dc_elt.className = 'bad';
			}
		}catch(err){
			loggerCentral('Stats Div not found.', 'debug');
		}
	}
	
	function grab_bonus(){
		AjxRequest('xw_controller=levelUpBonus&xw_action=addBonusItem&xw_city='+MyLocation()+'&mwcom=1&no_load=1&xw_client_id=8',function(page){
			if (page.indexOf('ERROR 500: response never closed')!=-1) {
				return;
			} else {
				var data = JSON.parse(page.replace(/^(\s\d\s+)/,''));
				updateStats('Levelup');
				$('#LastLevelup').html('<span class="good">Level <font color="gold">'+data.user_fields.user_level+'</font> You received: <font color="gold">'+data.bonusName+'</font></span>');
				update_game_ui_sp(data);
			}
		})
	}	

	function CloseDoopidPopup(){
		RatioChecker();
		var actualLevel = $('#user_level').text();
		if (actualLevel != Zangano.CurrentLevel){
			Zangano.CurrentLevel = $('#user_level').text();
			grab_bonus();
		}
		if($('.pop_bg').length>0){
			$('.pop_bg').each( function(){
				var id = this.id;
				MW.Popup.hide( id.substr( id.lastIndexOf("_") +1 ) );
			});
		}
	}
		   
   $("body").ajaxComplete(function (e, xhr, settings) {
   		if(Zangano.isRunning){
			RatioChecker();
			CloseDoopidPopup();
			var response = xhr.responseText;
			topMafiaResp(response);
			if ((/"group_atk"/.test(response))) {
				var b = eval('(' + response + ')');
				Zangano.userStats.group_atk = b.fightbar.group_atk;
				Zangano.userStats.group_def = b.fightbar.group_def;
				if(Zangano.userStats.firstRun) {
					Zangano.userStats.start_group_atk = b.fightbar.group_atk;
					Zangano.userStats.start_group_def = b.fightbar.group_def;
					document.getElementById('DX_atk_ttl').innerHTML = Zangano.userStats.group_atk;
					document.getElementById('DX_def_ttl').innerHTML = Zangano.userStats.group_def;
					Zangano.userStats.firstRun = false;
				}
				update_user_scores();
			}
		}
	});	
	
	function RatioChecker() { 
		document.getElementById('energy_ratio_reqd').innerHTML = (parseInt(document.getElementById('exp_to_next_level').innerHTML)/parseInt(document.getElementById('user_energy').innerHTML)).toFixed(3);
		document.getElementById('stamina_ratio_reqd').innerHTML = (parseInt(document.getElementById('exp_to_next_level').innerHTML)/parseInt(document.getElementById('user_stamina').innerHTML)).toFixed(3);
		document.getElementById('combined_ratio_reqd').innerHTML = (parseInt(document.getElementById('exp_to_next_level').innerHTML)/(parseInt(document.getElementById('user_energy').innerHTML)+parseInt(document.getElementById('user_stamina').innerHTML))).toFixed(3);
	}
	
	function topMafiaResp(response){
		var jobObj;
		var jobCostEnergy = 0;
		var jobCostStamina = 0;
		try{
			if(/Job Mastery: ([\d]+)%/.test(response)){//NY
				var msg = response;
				if(/: Completed/.test(msg)) {
					if (/As a Top Mafia Bagman/.test(msg)) {
						loggerCentral('bagman bonus', 'log');
						updateStats('bag');
					}
					if (/As a Top Mafia Mastermind/.test(msg)) {
						loggerCentral('mastermind bonus', 'log');
						updateStats('master');
					}
					if (/As a Top Mafia Wheelman/.test(msg)) {
						loggerCentral('wheelman bonus', 'log');
						updateStats('wheel');
					}
				}
			}else if(/masteryTotal/.test(response)){//Cities 7 onwards
				jobObj = JSON.parse(response);
				jobCostEnergy = parseInt(jobObj.jobResult.energy);
				jobCostStamina = parseInt(jobObj.jobResult.stamina);
				if (jobObj.jobResult.extraData.bonusCash > 0) {
					loggerCentral('bagman bonus', 'log');
					updateStats('bag');
				}
				if (jobObj.jobResult.extraData.bonusExperience > 0) {
					loggerCentral('mastermind bonus', 'log');
					updateStats('master');
				}
				if (jobCostEnergy == 0 && jobCostStamina == 0) {
					loggerCentral('wheelman bonus', 'log');
					updateStats('wheel');
				}
			}
		}catch(notjobbing){}
	}

	function updateStats(stats_div, multiple){
		RatioChecker();
		var multi = 1;
		if(multiple){
			multi = parseInt(multiple);
		}
		$('#'+stats_div).text(parseInt($('#'+stats_div).text()) + multi);
	}
	
	var checkTarget = false;
	var fightRuning = false;
	var activeCity;
	var prev_won = 0, prev_lost = 0;
	var singleTarget = [], targets = [], blacklist = [];

	$("#FAKE_target_url").change(function () {
		if(checkTarget){
			return;
		}
		checkTarget = true;
		$('#ADD_Kami').hide();
		$('#profileGood > img').attr('src',Zangano.Imgs.Loading);
		singleTarget = [];
		var m,famlink=$("#FAKE_target_url").val();
		if (m = /id=%7B%22user%22%3A%22([\w\d\%]+)%22%7D/.exec(famlink)) {
			var famid = atob(unescape(m[1]));
			load_profile(famid);
		}else{
			$('#profileGood > img').attr('src','https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/requests/cross.png');
			checkTarget = false;
		}	
	});
	
			
	function load_profile(id) {
		if (/p/.test(id)) {
			id = btoa(id);//cHwxNDYzODY2OTg=
		}
		AjxRequest('xw_controller=stats&xw_action=view&user='+id,function (response) { parse_profile_page(response); });
	}
	
	function parse_profile_page(response) {
		response = response.replace(/<img/ig, '<noimg');
		if (response.length == 0) {
			$("#FAKE_target_url").trigger('keyup');
			checkTarget = false;
			return;
		}
		try {
			var button = $(response).find('.impulse_buy:first').attr('href');
			if (button) {//not in mafia
				button = button.replace(/&amp;/g,'&').replace(/remote\/html_server.php\?/,'');
				var text = $(response).find('div[class*="stats_title"]').html();
				var family = $(response).find('div[class*="stats_title"] span:first').html();
				var level = 1;
				if (lev = /Level (\d+) (Fearless|Maniac|Mogul)/i.exec(text)) {
					level = parseInt(lev[1]);
				}
				var type = 'Unknown';
				if (ty = /Level (\d+) (Fearless|Maniac|Mogul)/i.exec(text)) {
					type = ty[2];
				}
				var name = 'NoName';
				if (na = /"(.*?)" level/.exec(text.replace(family,''))) {
					name = na[1];
				}

				if (/attack_pop/.test(button)) {
					var pid = /opponent_id=p%7C(\d+)/.exec(button)[1];
					singleTarget.push({"family":family,"name":name,"mafia":501,"pid":pid,"button":0,"iced":false,"family_id":0,"level":level,"type":type});
					$('#ADD_Kami').show()
					$('#profileGood > img').attr('src','https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/quest/checkbox_complete_28x28_01.png');
					checkTarget = false;
					//logit(JSON.stringify(singleTarget, null, 0));
					return;
				}
				else {
					$('#profileGood > img').attr('src','https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/requests/cross.png');
					checkTarget = false;
				}
			}else {
				var yours = $(response).find("a[href='javascript://']:first").attr('onclick');
				if(yours){ //in mafia
					yours = yours.replace(/&amp;/g,'&').replace(/remote\/html_server.php\?/,'');
					var text = $(response).find('div[class*="stats_title"]').html();
					var family = $(response).find('div[class*="stats_title"] span:first').html();
					var level = 1;
					if (lev = /Level (\d+) (Fearless|Maniac|Mogul)/i.exec(text)) {
						level = parseInt(lev[1]);
					}
					var type = 'Unknown';
					if (ty = /Level (\d+) (Fearless|Maniac|Mogul)/i.exec(text)) {
						type = ty[2];
					}
					var name = 'NoName';
					if (na = /"(.*?)" level/.exec(text.replace(family,''))) {
						name = na[1];
					}

					var pid = /opponent_id=p%7C(\d+)/.exec(yours)[1];
					if(pid){
						singleTarget.push({"family":family,"name":name,"mafia":501,"pid":pid,"button":0,"iced":false,"family_id":0,"level":level,"type":type});
						$('#ADD_Kami').show()
						$('#profileGood > img').attr('src','https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/quest/checkbox_complete_28x28_01.png');
						checkTarget = false;
					//	logit(JSON.stringify(singleTarget, null, 0));
						return;
					}
				}else{
					$('#profileGood > img').attr('src','https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/requests/cross.png');
					checkTarget = false;
				}
			}
		}
		catch (profile_error) {
			$('#profileGood > img').attr('src','https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/requests/cross.png');
			checkTarget = false;
		}
	}	
	
	function start_fighting(){
		if(!Zangano.isRunning){
			return;
		}
		if(!fightRuning){
			fightRuning = true;
			activeCity = jobArray[0].isCity;
			load_fightlist();
		}
	}

	function repeat_attack(instant) {
		if(!Zangano.isRunning){
			return;
		}
		var bankamount = parseInt($('#ZX_bankAbove').val());
		var user_stamina = parseInt($('#user_stamina').html());
		var user_health = parseInt($('#user_health').html());
		var user_health_limit = parseInt($('#ZX_healAbove').val());

		if (fightRuning) {
			if (activeCity != jobArray[0].isCity) {
				loggerCentral('City change detected! Travelling back to start city.','log');
				travel(jobArray[0].isCity,activeCity);
				return;
			}else if (user_health < user_health_limit) {
				visit_hospital();
				return;
			}else if(user_stamina < 5) {
				fightRuning = false;
				setTimeout(function(){checkResources();},100)
			}else{
				if(jobArray[0].isKami) {
					var now = unix_timestamp();
					if (start_time == 0) {
						start_time = parseInt(new Date().getTime().toString().substring(0, 10));
					}
					var xyz = age(parseInt(now-start_time))
					if($('#ZX_FO_P5').is(':checked') && xyz > 4){
						loggerCentral('Waiting 5 minutes for XP snafu..','status');
						loggerCentral('Waiting 5 minutes for XP snafu..','log');						
						setTimeout(function(){start_time = 0;repeat_attack();},60*1000*5);
						return;
					}
				}
				if (instant) {
					do_attack();
				}else {
					loggerCentral('Attacking again in..','status');
					setTimeout(function(){do_attack();},350);
				}
				return;
			}
		}
	}	
	
	function age(diff) {
		if (diff == 0) {
			return 0;
		}
		diff*=1000;
		var hours = Math.floor(diff / (60 * 60 * 1000));
		diff -= hours * (60 * 60 * 1000);
		var minutes = Math.floor(diff / (60*1000));
		diff -= minutes * 60 * 1000;
		var seconds = Math.floor(diff / 1000);
		return minutes;
	}
	
	function travel(to,from) {
		var url = 'xw_controller=travel&xw_action=travel&destination='+to+'&from=fight';
		loggerCentral('Travelling from '+from+' to '+to+'...','status');
		AjxRequest(url,function(s) { parse_travel(s); });
	}

	function parse_travel(response) {
		loggerCentral('Reading travel response...','log');
		activeCity = /xw_city=(\d+)/.exec(response)[1];
		repeat_attack();
	}
	
	function visit_hospital() {
		var hospital_city = $('#ZX_healCity').val();
		if ((activeCity == hospital_city) || (hospital_city == 1)) {
			loggerCentral('<span class="good">Going to hospital...</span>','status');
			var url = 'xw_controller=hospital&xw_action=heal&xw_city=';
			if (hospital_city == 1) {
				url = url+'&xcity=1';
			}
			AjxRequest(url,function(response){ parse_hospital(response); },function(s){loggerCentral('Page not loaded properly, trying again in 2 seconds','status');setTimeout(function(){repeat_attack();},2000);})
		}else {
			loggerCentral('<span class="good">Travelling to hospital city...</span>','status');
			travel(hospital_city,activeCity);
		}
	}
	
	function parse_hospital(hospital) {
		var object = jQuery.parseJSON(hospital.replace(/^(\s\d\s+)/,''));
		update_game_ui(object);
		loggerCentral(object.hospital_message,'status');
		if (/You cannot heal so fast/.test(object.hospital_message)) {
			if (Util.isset(object.waitHealTimer)) {
				//Thanks to David Van G. for this find
				loggerCentral('Heal possible in '+object.waitHealTimer+' seconds.','status');
				setTimeout(function(){repeat_attack();},object.waitHealTimer);
				loggerCentral('Retrying heal in ...','log');
			}else {
				setTimeout(function(){repeat_attack();},5000);
				loggerCentral('Retrying heal in ...','status');
			}
			return;
		}else {
			var hospital_city = $('#ZX_healCity').val();
			if (jobArray[0].isCity != activeCity && activeCity == hospital_city) {
				loggerCentral('<span class="sexy_travel_new">Travelling back to fight city...</span>','status');
				travel(jobArray[0].isCity,activeCity);
			}else {
				repeat_attack();
			}
		}
	}
	
	function update_game_ui(object) {
		if (Util.isset(object.user_fields)) {
			user_fields_update(object.user_fields);
			user_info_update(object.user_fields, object.user_info);
			if (Util.isset(object.user_fields.current_city_id)) {
				activeCity = object.user_fields.current_city_id;
			}
		}
		if (Util.isset(object.questData)) {
			MW.QuestBar.update(object.questData);
		}
	//	if (Util.isset(object.fightbar)) {
	//		stats.attack = parseInt(object.fightbar.group_atk);
	//		stats.defense = parseInt(object.fightbar.group_def);
	//	}
	}
	
	function do_attack() {
		if(!Zangano.isRunning){
			return;
		}
		if (targets.length == 0) {
			targets = [];
			loggerCentral('Ran out of targets, reloading fight list in 3 seconds','status');
			setTimeout(function(){load_fightlist();},3000);
			return;
		}
		if(jobArray[0].isKami) {
			var temp = targets[0].button;
			temp = temp.replace(/opponent_id=p%7C\d+/,'opponent_id=p%7C'+singleTarget[0].pid);
			targets[0] = singleTarget[0];
			targets[0].button = temp;
//			logit(JSON.stringify(targets, null, 0));
		}
		if (fightRuning) { 
			if (check_name(targets[0].name+targets[0].family) && !jobArray[0].isKami) {
				loggerCentral('Skipping '+profile_link()+' because of name filter.','status');
				skip_target();
				repeat_attack(true);
			}
			else if (check_family(targets[0].family_id) && (targets[0].family_id > 0) && !jobArray[0].isKami) {
				loggerCentral('Skipping '+profile_link()+' because of family filter.','status');
				skip_target();
				repeat_attack(true);
			}
			else if (find_element(targets[0].pid,'pid',blacklist) && $('#ZX_blacklist').is(':checked') && !jobArray[0].isKami) {
				loggerCentral('Skipping <a href="http://apps.facebook.com/inthemafia/profile.php?id=%7B%22user%22%3A%22'+btoa('p|'+targets[0].pid)+'%22%7D">'+targets[0].family+' '+targets[0].name+'</a> because of blacklist. <span class="more_in">(Stronger opponent)</span>','status');
//				stats.blacklist++;
				skip_target();
				repeat_attack(true);
			}else {
				if(jobArray[0].isKami) {
					loggerCentral('Attacking '+profile_link()+'...','status');
				}else{
					loggerCentral('<a href="#" id="skip_the_target">(Skip)</a> Attacking '+profile_link()+'...','status');
					$('#skip_the_target').bind('click',function() {
						loggerCentral('Manually skipped '+profile_link(),'status');
						skip_target();
						return false;
					});
				}
				AjxRequest(targets[0].button,function(s){ parse_attack(s); },function(s){ loggerCentral('Page not loaded properly, trying again in 2 seconds.','status');setTimeout(function(){repeat_attack();},2000);});
			}
		}
	}
	
	function load_fightlist() {
		loggerCentral('Loading fight list...','status');
		var url = 'xw_controller=fight&xw_action=view';
		AjxRequest(url,function(response){ parse_fightlist(response,true); });
	}
	
	function parse_fightlist(response,attack) {
		if (/ERROR 500/.test(response)) {
			loggerCentral('Game responded with Error 500, multiple action blocked. Retry in 2 seconds','status');
			setTimeout(function(){repeat_attack();},2000);
			return;
		}
		if (!attack) {
			var tmptarget = targets[0];
			targets = [];
			if (!tmptarget.iced) {
				targets.push(tmptarget);
			}
		}
		$('#user_health').html(parseInt(/user_health.*?(\d+)/.exec(response)[1]));
		
		$(response).find('tr').filter(function() {
			return $(this).parent().parent().attr('cellspacing') == '0';
		}).each(function(index) {
			$this = $(this);
			var family = '';
			var family_id = 0;
			if ($this.find('td:first a').size() == 2) {
				family = $this.find('td:first a').eq(0).text();
				try {
					family_id = atob(unescape(/id=([a-zA-Z0-9%]+)/.exec($this.find('td:first a').eq(0).attr('href'))[1]));
				} catch(e) { family_id=null; }
			}
			var name = $this.find('td:first a:last').text();
			if (name) {
				var level = $this.find('.fight_list_level_alive,.fight_list_level_dead').text();
				try {
					var type = /(Fearless|Maniac|Mogul)/.exec($this.find('td:first').html())[1];
				} catch(e) { type="unknown"; }
				$this.find('td.fight_list_player_diff_level').remove();
				var mafia = $this.find('td').eq(1).html().trim();
				var iced = $this.find('td:first').hasClass('fight_list_player_dead');
				var button = $this.find('td.action a:first').attr('href').replace(/&amp;/g,'&').replace(/remote\/html_server.php\?/,'');
				var pid = /btn_attack_p(\d+)/.exec(button)[1];
				if (!iced) {
					if (!find_element(pid,'pid',targets)) {
						targets.push({"pid":pid,"button":button,"iced":iced,"mafia":mafia,"name":name,"family":family,"family_id":family_id,"level":level,"type":type});
					}
				}
			}
		});
		if (attack && fightRuning) {
			repeat_attack();
		}
	}
	
	function check_name(name) {
		var characters = $('#ZX_namefilter').val().trim().split(/[ \n]/);
		for (var i = 0; i < characters.length; i++) {
			characters[i] = characters[i].replace(/[\s\r\n]/g, '');
			if (characters[i].length > 0) {
				if (name.indexOf(characters[i]) > -1) {
					return true;
				}
			}
		}
		return false;
	}

	function check_family(id) {
		var families = $('#ZX_familyfilter').val().trim().split(/[ \n]/);
		for (var i = 0; i < families.length; i++) {
			families[i] = families[i].replace(/[\s\r\n]/g, '');
		}
		if (families.indexOf(id+"") != -1) {
			return true;
		}
		return false;
	}
	
	function profile_link() {
		if (!isNaN(targets[0].family_id) && targets[0].family_id > 1) {
			return '<a href="http://apps.facebook.com/inthemafia/family.php?id=%7B%22id%22%3A%22'+btoa(targets[0].family_id)+'%22%7D" target="_blank" title="Family id '+targets[0].family_id+'"><span style="color:red;">'+targets[0].family+'</span></a> <a href="http://apps.facebook.com/inthemafia/profile.php?id=%7B%22user%22%3A%22'+btoa('p|'+targets[0].pid)+'%22%7D">'+targets[0].name+'</a>';
		}
		else {
			return '<a href="http://apps.facebook.com/inthemafia/profile.php?id=%7B%22user%22%3A%22'+btoa('p|'+targets[0].pid)+'%22%7D">'+targets[0].name+'</a>';
		}
	}
	
	function find_element(search,property,array) {
		for (var x in array) {
			if (search == array[x][property]) {
				return array[x];
			}
		}
		return false;
	}
	
	function skip_target() {
		if(!jobArray[0].isKami){
			loggerCentral('Skipping target...','status');
			targets.shift();
		}
	}
	
	function parse_attack(response) {
		var fightResult = false;
		var object = {};

		if (/index_controller/.test(response)) {
			//Session most likely timed out
			targets = [];
			load_fightlist();
			return;
		}else if (/fight_wrapper/.test(response)) {
			if (/This player is currently part of your mafia/i.test(response)) {
				if(jobArray[0].isKami) {
					loggerCentral('Removing from mafia','status');
					var removeURL = $(response).find('a.sexy_button_new:contains("Remove from Mafia")').attr('href');
					AjxRequest(removeURL,function(s) { parse_remove(s); },function(s){ loggerCentral('Page not loaded properly, trying again in 2 seconds.','status');setTimeout(function(){repeat_attack();},2000);});
				}else{
					skip_target();
					repeat_attack();
				}
				return;
			}
			if (fight_result = /msg.fight_result = (\{.*\});FightV2/.exec(response)) {
				var user_data = [];
				user_data = create_user_data(response);
				object['user_fields'] = user_data[0];
				object['user_info'] = user_data[1];
				if (quest = /MW.QuestBar.update\((\{.*\})\);/.exec(response)) {
					object['questData'] = quest[1];
				}
				update_game_ui(object);
				object['popup'] = response;

				if (/table class="main_table fight_table" cellspacing="0"/.test(response)) {
					parse_fightlist(response,false);
				}

			}else {
				user_data = create_user_data(response);
				object['user_fields'] = user_data[0];
				object['user_info'] = user_data[1];
				update_game_ui(object);
				repeat_attack();
				return;
			}
		}else if (/ERROR 500/.test(response)) {
			loggerCentral('Game responded with Error 500, multiple action blocked. Retry in 2 seconds','status');
			setTimeout(function(){repeat_attack();},2000);
			return;
		}else {
			try {
				object = jQuery.parseJSON(response.replace(/^(\s\d\s+)/,''));
				update_game_ui(object);
			} catch(UnexpectedTokenError) {}
		}

		if (Util.isset(object.fight_result)) {
			fightResult = object.fight_result;
		}
		if (Util.isset(object.popup) && !fightResult) {
			if (/msg.fight_result = false/.test(object.popup)) {
				repeat_attack();
				return;
			}else {
				if (res = /msg.fight_result = (\{.*\});FightV2/.exec(object.popup)) {
					fightResult = jQuery.parseJSON(res[1]);
				}else {
					repeat_attack();
					return;
				}
				if ($('#ZX_power').is(':checked')) {
					var url = $(object.popup).find('.fightV2AttackBtn').eq(3).attr('href');
					targets[0].button = url.substr(url.indexOf('?')+1);
				}else {
					var url = $(object.popup).find('.fightV2AttackBtn:first').attr('href');
					targets[0].button = url.substr(url.indexOf('?')+1);
				}
			}
		}

		if (fightResult) {
			var multiplier = 1;
			if (fightResult.cash_class != 'new_york') {
				multiplier = 5;
			}

			var attacks_won = parseInt(fightResult.power_attack.won-prev_won);
			var attacks_lost = parseInt(fightResult.power_attack.lost-prev_lost);
			var attacks_made = parseInt((attacks_won+attacks_lost) * multiplier);

			//stats.stamina_used += attacks_made;
			//stats.attacks_done += attacks_made;

			//stats.success += attacks_won * multiplier;
			//stats.failed += attacks_lost * multiplier;
			updateStats('ZX_won', (attacks_won * multiplier));
			updateStats('ZX_lost', (attacks_lost * multiplier));
			prev_won = parseInt(fightResult.power_attack.won);
			prev_lost = parseInt(fightResult.power_attack.lost);

			var ice_output = '';
			var ice_css = 'color:#609AD1;';
			if (fightResult.defender.is_iced || fightResult.defender.is_killed) {
				ice_output = 'already iced!';
				//stats.already_iced++;
				targets[0].iced = true;
			}
			if (fightResult.defender.iced_self) {
				ice_output = 'iced self!';
				targets[0].iced = true;
			}
			if (fightResult.defender.you_iced) {
				//stats.iced++;
				updateStats('ZX_iced');
				ice_output = 'iced!';//+iced_image;
				ice_css = 'color:#609AD1;font-weight:bold;';
				targets[0].iced = true;
			}
			if (fightResult.defender.is_killed && fightResult.defender.you_iced) {
				//stats.killed++;
				//stats.iced++;
				updateStats('ZX_killed');
				ice_output = 'killed!';
				ice_css = 'color:#990000;font-weight:bold;';
				targets[0].iced = true;
			}

			var output = '';
			if (fightResult.isWin) {
				output += 'Won! ';
			}else {
				output += '<span class="bad">Lost!</span> ';
				add_blacklist();
			}
			if (fightResult.use_boost) {
				output += boost_image+' ';
			}
			if (Util.isset(object.user_fields)) {
				output += '<span class="experience" title="Experience gained">'+object.user_fields.xp_earned+'</span> ';
			}
			if (Util.isset(fightResult.defender.damage_dealt)) {
				var damage = parseInt(fightResult.defender.damage_dealt);
				output += ' <span class="attack" title="Damage done.">'+damage+'</span> ';
			}

			fightResult.defender.is_iced ? output += 'Target <span style="'+ice_css+'">'+ice_output+'</span> ' : '';
			output += profile_link()+' ';
			loggerCentral(output,'log');

			if (fightResult.ice_was_just_stolen) {
				var stealer = fightResult.thief_name;
				if (fightResult.thief_isInMafia) {
					loggerCentral('Ice stolen by mafia member '+fightResult.thief_profile+'!','log');
				}else {
					loggerCentral('Ice stolen by '+fightResult.thief_profile+'!','log');
				}
			}
			
			if (Util.isset(object.popup) && Util.isset(object.popup_id)) {
				if (promotion=/You are now LEVEL (\d+)/i.exec(object.popup)) {
					loggerCentral('Levelup!','status');
					grab_bonus();
					fightRuning = false;
					setTimeout(function (){checkResources();},1000);
					return;
				}
			}
			
			if (fightResult.defender.is_iced) {
				if(!jobArray[0].isKami){
					skip_target();
					repeat_attack();
				}else{
					var wait = parseInt($('#DX_FO_RCT').val())
					loggerCentral('Target is Iced, Attacking again in '+wait+' seconds','status');
					setTimeout(function (){repeat_attack();},wait*1000);
				}
				return;
			}
			if (!fightResult.isWin) {
				if (!$('#ZX_redice').is(':checked')||!jobArray[0].isKami) {
					skip_target();
				}
				repeat_attack();
				return;
			}
			if (fightResult.isWin && !fightResult.defender.is_iced) {
				loggerCentral('Attacking again!','log');
				targets[0].button = targets[0].button.replace(/click_amt=1/,'click_amt='+$('#ZX_burst').val());
				repeat_attack();
				return;
			}
		}else {
			loggerCentral('No fight result to parse... Stamina: '+User.stamina+' Health: '+User.health,'log');
			if (User.health < parseInt($('#ZX_healAbove').val())) {
				loggerCentral('<span class="good">Going to hospital...</span>','status');
				var url = 'xw_controller=hospital&xw_action=heal&xw_city=&xcity=1';
				AjxRequest(url,function(response){ parse_hospital(response); });
			}else {
				repeat_attack();
			}
		}
	}
	
	function add_blacklist() {
		if (!find_element(targets[0].pid,'pid',blacklist)) {
			blacklist.push(targets[0]);
		}
	}
	
	function parse_remove(response){
		if(/was removed from your mafia/.test(e)){
			loggerCentral('was removed!','debug')
			repeat_attack();
		}
	}

	function startSpart(){
		if(!arenaRunning) {
			arenaRunning = true;
			join_arena();
		}
	}
	
	function join_arena() {
		/* initialize vars */
		cmdqueue=[];
		meid=null;
		meteam=null;
		poweratt = undefined;
		poweruplist = {};
		playerinfo={};
		playerids={};
		stam_on_start = -1;
		powerup_status = {};
		powerup_command = { count:{},active:-1,target:undefined };
		da_game = [];
		protect = {};
		$('span[id*="ZX_Spart_rank"]').html('');
		$('span[id*="ZX_Spart_pu"]').html('');
		$('span[id*="ZX_Spart_name"]').html('');
		$('span[id*="ZX_Spart_respect"]').html('');
		$('span[id*="ZX_Spart_diff"]').html('');
		$('span[id*="ZX_Spart_health"]').html('');
		$('span[id*="ZX_Spart_score"]').html('');
		$('span[id*="ZX_Spart_usepu"]').html('');
		/* join */
		loggerCentral('Joining arena...', 'log');
		var DoesIHaveStamina = parseInt(document.getElementById('user_stamina').innerHTML);
		if(DoesIHaveStamina == 0){
			DoesIHaveStamina = parseInt($('#ZX_Spart_me_st').text());
		}
		var type = $('#ZX_Spart_arenatype').val();
		if(type == "hw" && $('#arena_switch').is(':checked') && DoesIHaveStamina <= $('#arena_switch_v').val()) {
			loggerCentral('Switched arenas to 100 stamina ones...', 'log');
			type = "lw";
		}
		replenish=(type=="sw"?2:(type=="lw"?10:50));
		$('#ZX_Spart_replenish').text(replenish);
		var gametype = '';
		if($('#ZX_Spart_mobfury').is(':checked')) { gametype = '&arenaGameType=2'; }
		AjxRequest('xw_controller=Lobby&xw_action=join_arena&arenaType='+type+gametype+'&xw_client_id=8',function(msg){
			//console.log(msg);
			var json = JSON.parse(msg);
			if(json.data.success == 1) {
				arenaRunning = true;
				if(json.data.message=="User is in another arena") {
					loggerCentral('Successfully re-joined Arena.', 'log');
				} else {
					loggerCentral('Successfully joined Arena.', 'log');
				}
				$('#user_stamina').text('0');
				load_arena();
			}
			else {
				if (json.data.message.indexOf('Refresh to claim your rewards from the previous Arena')!=-1) {
					loggerCentral('Claiming your rewards from the previous Arena', 'log');
					get_rewards();
				}
				else if(json.data.message.indexOf('have enough stamina to join this arena')!=-1) {
					loggerCentral('Not enough Stamina, stopping.', 'log');
					$('#ZX_Spart_table').html(optable);
					checkResources();
				}else if(json.data.message.indexOf('Unable to join')!=-1) {
					var wait = Math.floor(Math.round((Math.random() * 8))+2);
					loggerCentral('Unable to join this Arena. Join another one. Trying again..', 'log');
					setTimeout(join_arena,wait*1000);
				}
				else {
					loggerCentral('Successfully joined Arena.', 'log');
					arenaRunning = false;
				}
			}

		},function(){
			loggerCentral('Error on trying to join arena, retrying in 30 seconds...', 'log');
			setTimeout(join_arena,30000);
			// script ends here
		});
	}

	function load_arena(){
		AjxRequest('xw_controller=Lobby&xw_action=loadArena&xw_client_id=8&exit=t',function(msg){
			var m;
			if(m = /viewObj.init\(\"([^\"]*)\",/.exec(msg)) {
				var wslink = m[1];
				connect_arena(wslink);
			}
		},function(){
			loggerCentral('Error on trying to load', 'log');
		});
	}

	function connect_arena(sockenurl) {
		socke=new WebSocket(sockenurl);
		socke.onopen=function(){
			loggerCentral('Connected to Arena.','log');
			$('#ZX_Spart_table').html(optable);
			conn_checker = setInterval(check_connection,100);
			reconnect_retry = 0;
		};
		socke.onmessage=function(msg){
			var json=JSON.parse(msg.data);
			try {
				if((json.mi.ammo==-1) && (json.ac)) {
					if(json.ac.substr(0,1)=="2") {
						if(json.ac.substr(2,1)=="1") {
							loggerCentral('Successfully escaped! Brave Sir Robin ran <a href=\"http://www.youtube.com/watch?v=BZwuTo7zKM8&feature=player_detailpage#t=59s\" target=\"_blank\">away away!</a>','log');
							AjxRequest('xw_controller=lobby&xw_action=leaveArena&xw_city=&xw_person=&xw_client_id=8',function(){
								loggerCentral('Stamina retrieved.','log');
								$('#status').html('Waiting for Start.');
							});
						} else {
							loggerCentral('Could not leave, too late. You are trapped in here, good luck.','log');
						}
					}
				}
			} catch(all) {console.log(all);}
			update_info(json);
			decide_actions();
			send_queue();
		};
		socke.onclose=function(){
			last_update=0;
			clearInterval(conn_checker);
			$('#ZX_Spart_connstatus').html('-');
			set_progress_bar(0,0,'');
			if(currdata && (currdata.s==2)) {
				console.log(currdata);
				try {
					if((currdata.s<1) && (currdata.mi.ammo==-1)){
						arenaRunning = false;
						return;
					}
				} catch(all) {console.log(all);}
				reconnect_retry++;
				if(currdata.t<3) {
					loggerCentral('Connection closed in the last seconds, might be normal. Claiming rewards in a few...','log');
					setTimeout(get_rewards, currdata.t*2000);
				} else if(reconnect_retry>5) {
					loggerCentral('Lost connection 5 times in a row, not retrying again.','log');
					checkResources();
				} else {
					loggerCentral('Probably lost connection, reconnecting','log');
					join_arena();
				}
			} else if (currdata.s==4) {
				loggerCentral('Closed connection, challenge decline or expired.','log');
				AjxRequest('xw_controller=lobby&xw_action=leaveArena&xw_city=&xw_person=&xw_client_id=8',function(){
					loggerCentral('Stamina retrieved.','log');
					$('#status').html('Waiting for Start.');
					arenaRunning = false;
					checkResources();
				});	
			}else{
				reconnect_retry = 0;
				get_rewards();
			}
		};
	}

	function check_connection(){
		if(!arenaRunning) {
			clearInterval(conn_checker);
		}
		if(last_update>0){
			var res,gap=(new Date()).getTime()-last_update;
			if(gap<600) {
				res='<span class="good">Good!</span>';
			} else if(gap<1200) {
				res='<span style="color:orange;font-weight:600;">Slow...</span>';
			} else {
				res='<span class="bad">Stalled!</span>';
			}
			$('#ZX_Spart_connstatus').html(res);
		}
	}

	function am_i_leading_by(points) {
		var i,best_player_points=0;
		for(i in currdata.pi) {
			if(i!=meid) {
				if(currdata.pi[i].sc>best_player_points) { best_player_points=currdata.pi[i].sc;}
			}
		}
		var my_score=currdata.pi[meid].sc;
		return my_score-points>best_player_points;
	}

	function are_we_leading_by(points) {
		var team1 = parseInt(tscore["1"]);
		var team2 = parseInt(tscore["2"]);
		if (meteam == 1) {
			return team1-points>team2;
		}
		else {
			return team2-points>team1;
		}
	}

	function am_i_targeting(points,targetrank) {
		var scores=[];
		for(i in currdata.pi) {
			if(i!=meid) {
				scores.push(currdata.pi[i].sc);
			}
		}
		scores.sort(function(a,b){return b-a;});
		var my_score=currdata.pi[meid].sc;
		return my_score-points>scores[targetrank-1];
	}
			
	function decide_allowed_to_attack(){
		try {
			var stopon = $('#ZX_Spart_stopon').val();
			var stoponval = parseInt($('#ZX_Spart_stoponvalue').val());
			var stamused = stam_on_start-currdata.mi.st;
			var score = currdata.pi[meid].sc;
			if(currdata.pi[meid].ph==0) { return false; } // me dead
			if(currdata.mi.st<10) { return false; } // no stam
			if((currdata.mi.st<50) && (poweratt)) { return false; } // no stam
			switch(stopon) {
				case "never": return true;
				case "stop": return false;
				case "teamleading": return !are_we_leading_by(stoponval);
				case "leading": return !am_i_leading_by(stoponval);
				case "leading3": return !am_i_targeting(stoponval,3);
				case "leading5": return !am_i_targeting(stoponval,5);
				case "staminaused": return stamused<stoponval;
				case "staminaleft": return currdata.mi.st>stoponval;
				case "score": return score<stoponval;
				case "stars": return currdata.ti[meteam].stars<stoponval;
			}
		} catch(err) {}
		return true;
	}

	function decide_who_to_attack(count){
		var i,list=[];
		if(powerup_command.target!==undefined) {
			if((currdata.pi) && (currdata.pi[powerup_command.target]) && (currdata.pi[powerup_command.target].ph>0)) {
				for(i=0;i<count;i++) {
					list.push(powerup_command.target);
				}
				return list;
			} else {
				powerup_command.target = undefined;
				$('.ZX_Spart_kill').removeClass('ZX_Spart_puactive').addClass('ZX_Spart_punormal');
			}					
		}
		var target=$('#ZX_Spart_seltarget').val();
		if(powerup_status.kami_active) { target="highhealth"; }
		var skipshield_d=$('#ZX_Spart_skipshield').is(':checked');
		var skipshield_a=$('#ZX_Spart_skipshield_a').is(':checked');
		var bestid=-1,best=0;
		for(i in currdata.pi) {
			if(i!=meid) {
				if(!protect[i]) {
					if((!meteam) || (currdata.pi[i].tm!=meteam)) {
						if((currdata.pi[i].ph>0)) {
							if(!((skipshield_d && (currdata.pi[i].pu>1)) || (skipshield_a && (currdata.pi[i].pu%2==1)))){
								var val;
								switch(target) {
									case "lowhealth": val=100-currdata.pi[i].ph; break;
									case "highhealth": val=currdata.pi[i].ph; break;
									case "leastpoints": val=1000000-currdata.pi[i].sc; break;
									case "mostpoints": val=currdata.pi[i].sc;break;
									case "leastrespect": val=10000-playerinfo[i].respect; break;
									case "mostrespect": val=playerinfo[i].respect; break;
									case "allalive": val=1; break;
									case "leastdiff": val=3-r_difficulty[playerinfo[i].diff]; break;
								}
								if(val>best) {
									list=[];
									list.push(i);
									best=val;
								} else if(val==best) {
									list.push(i);
								}
							}
						}
					}
				}
			}
		}
		if(list.length==0) {
			//console.log('doh, no target.');
		} else if(list.length>count) {
			list=list.slice(0,count);
		} else if(list.length<count) {
			while(list.length<count) {
				list.push(list[0]);
			}
		}
		return list;
	}

	function decide_actions(){
		var numatt = parseInt($('#ZX_Spart_numatt').val()) || 3;
		if(numatt>3) { numatt=3; }
		
		if(currdata.s==2) { // fight active
			if($('#ZX_Spart_powerattack').is(':checked')) {
				poweratt_on();
			} else {
				poweratt_off();
			}
			// power ups
			var usekami=$('#ZX_Spart_boostkami').is(':checked');
			if(usekami && !powerup_status.kami_used) {
				var kamitime = parseInt($('#ZX_Spart_boostkami_s').val());
				if(currdata.t<kamitime) {
					use_powerup(5);
				}
			}
			
			// send queued powerup
			if(powerup_command.active!=-1) {
				cmdqueue.unshift('3:'+powerup_command.active);
				if ((powerup_command.active==1) || (powerup_command.active==2)) { // don't retry heal or stam refill
					powerup_command.active = -1;
					$('.ZX_Spart_boost.ZX_Spart_puactive').removeClass('ZX_Spart_puactive').addClass('ZX_Spart_punormal');
					$('.ZX_Spart_boost2.ZX_Spart_puactive').removeClass('ZX_Spart_puactive').addClass('ZX_Spart_punormal');
				}
			}

			if(decide_allowed_to_attack()) {
				var i,who=decide_who_to_attack(numatt-cmdqueue.length);
				for(i=0;i<who.length;i++) {
					attack(who[i],1);
				}
			}
			//console.log(cmdqueue);
		}
	}	
	
	function get_rewards() {
		AjxRequest('xw_controller=Arena&xw_action=rewards&xw_client_id=8',function(msg){
			parse_loot(msg);
			setTimeout(function(){ getStats(display_all_stats); },2000);
			arenaRunning = false;
			setTimeout(function(){ checkResources(); },3000);
		});
	}
		
	function update_crests(){
		AjxRequest('xw_controller=lobby&xw_action=play',function(resp){
			check_levelup(resp);
			var $page = $('<div>'+resp+'</div>');
			var crests = parseInt($page.find('.mastery_stat_cont').find('.respect_value').text());
			var output = '';
			if(!isNaN(crests)){
				if(last_crests){
					output += crests+'<span class="good">(+'+(crests-last_crests)+')</span>';
				}
				else{
					output += crests;
					last_crests = crests;
				}
			}
			$('#ZX_Spart_crests').html(output);
		},$.noop)
	}	
	
	function load_player_profile(id,nr) {
		$('#ZX_Spart_infobox'+nr).attr('spdone','true');
		AjxRequest('xw_controller=stats&xw_action=view&user='+btoa('p|'+id),function(result){
			var $msg=$('<div>'+result.replace(/<img/g,'<noimg')+'</div>');
			window.eike1=result;
			window.eike2=$msg;
			try {
				var name=$msg.find('.stats_title_text').html().re('a> ([^>]*)"');
				var level=$msg.find('.stats_title_text').html().re('level (\\d*)');
				var tag=$msg.find('.stats_title_text > a').text().trim();
				var llink=$msg.find('.stats_title_text > a').attr('href');
				var arena_stats=$msg.find('#arena_collection .collection_list').text().trim().replace(/s*\n\s*/g,"<br />").replace(/:/g,': ');
				var mafia=$msg.find('a:contains("Ask Mafia to Attack")').length==0;
				var fid=atob(unescape(llink.re('id=([^&]*)&')));
			} catch(nofam) {
				var name=$msg.find('.stats_title_text').text().trim().re('"(.*)"');
				var tag="no family";
				var llink='';


			}
			var html='Full name: '+name+'<br />'+
			'Family: '+tag+' ('+fid+')<br/>'+
			'Level: '+level+'<br />'+
			(mafia?'<span class="good">In your mafia</span>':"Not a mafia member")+'<br /><br />'+
			arena_stats;
			$('#ZX_Spart_infobox'+nr).html(html);
			if(tag&&llink) {
				$('#ZX_Spart_hover'+nr+' > img').after(
					'<a href="http://'+zserver+'.mafiawars.zynga.com/mwfb/remote/html_server.php?xw_controller=clan&xw_action=view&xw_city=7&mwcom=1&id='+escape(btoa(fid))+'&from_red_link=1" class="mw_new_ajax" selector="#inner_page"><span style="color:red">'+tag+'</span></a> '
				);
			}
		});
	}

	function write_arenas(){
		var i,score,html='';
		for(i=0;i<arenalist.length;i++){
			var type,arena=arenalist[i];
			if (arena.opponents > 2) {
				type = 'Rank: '+arena.rank+" of "+arena.opponents;
				score = 'Score: '+arena.points;
			}
			if (arena.opponents < 3) {
				type = (arena.rank==1?'Won':'Lost')+" against "+arena.opponentname;
				score = 'Score: '+arena.points;
			}
			if (arena.type == 'mobfury') {
				type = 'MobFury '+(arena.rank==1?'Victory':'Loss');
				score = 'Red: '+arena.teamred+' vs Blue: '+arena.teamblue;
			}
			html += 'Arena #'+(i+1)+' '+type+', '+score+', Stamina: '+arena.stam+(arena.crests?', Crests:'+arena.crests:'');
			html+='<br />';
		}
		$('#ZX_Spart_arenalog').html(html);
	}
	
	function get_stage(i) {
		if(i==0) { return "Waiting for more players.."; }
		if(i==1) { return "Waiting for Start."; }
		if(i==2) { return "Fighting!"; }
		if(i==3 && stopAFTR) { 
			return; 
		}else if(i==3 && !stopAFTR) { return "Finished"; }
		if(i==4) { return "Waiting for Opponent(s)..."; } // challenge mode
		return "Unknown:"+i;
	}

	function send_queue() {
		if(cmdqueue.length>0) {
			var string='{"Nonce":'+currdata.mi.ammo+',"CMD":"'+cmdqueue.join(';')+'"}'
			cmdqueue=[];
			socke.send(string);
		}
	} 

	function attack(i,num) {
		var j;
		for(j=0;j<num;j++) {
			cmdqueue.push("1:"+i);
		}
	}

	function poweratt_on() {
		if(poweratt!==true) {
			cmdqueue.push("2:1");
			poweratt=true;
		}
	}

	function poweratt_off() {
		if(poweratt!==false) {
			cmdqueue.push("2:0");
			poweratt=false;
		}
		return false
	}

	function use_powerup(id) {
		powerup_command.active=id;
		powerup_command.target=undefined;
	}

	function update_info(data) {
		if(data.s==2) {
			// update last data received
			if(last_update>0) {
				var newtime=(new Date()).getTime();
				$('#ZX_Spart_delay').text((newtime-last_update)+'ms');
				last_update=newtime;
			} else {
				last_update=(new Date()).getTime();
			}
		}

		set_progress_bar(data.t,data.s==2?90:20,data.t+' seconds left');

		// counter
		if(data.s==1) {
			starting_in = unix_timestamp()+data.t;
			clearInterval(starting_in_counter) ;
			starting_in_counter = setInterval(function(){
				if(starting_in < unix_timestamp()) {
					clearInterval(starting_in_counter) ;
				} else {
					set_progress_bar(parseInt(starting_in - unix_timestamp()),20,starting_in - unix_timestamp()+' seconds left');
				}
			},1000);
			if(data.mi) {
				stam_on_start = data.mi.st; // save at start
			}
		}else {
			clearInterval(starting_in_counter);
		}


		if(data.mi && (stam_on_start==-1)) {
			stam_on_start = data.mi.st;
		}

		$('#status').html(get_stage(data.s));
		if(data.s<1) {
			$('#status').append(' <a href="#" id="ZX_Spart_leave">(leave)</a>');
			$('#ZX_Spart_leave').click(function(){
				socke.send('{"Nonce":-1,"CMD":"2"}');
				return false;
			});
		}

		tscore={"1":0,"2":0};
		
		// enemy powerups
		for(i in data.pi) {
			var pi=data.pi[i];
			// thanks Alex for this idea
			if(pi.ph == 0){
				if(healtimer[i]<10) {
					healtimer[i] = unix_timestamp() + 10;
					$('#ZX_Spart_usepu'+i+' > .ZX_Spart_boost').removeClass('ZX_Spart_puclick').addClass('ZX_Spart_punoclick').removeClass('ZX_Spart_pufull').addClass('ZX_Spart_puoff');
					$('#ZX_Spart_usepu'+i+' > .ZX_Spart_kill').removeClass('ZX_Spart_puclick').addClass('ZX_Spart_punoclick').removeClass('ZX_Spart_pufull').addClass('ZX_Spart_puoff');
					$('#ZX_Spart_usepu'+i+' > .ZX_Spart_boost2').removeClass('ZX_Spart_punoclick').addClass('ZX_Spart_puclick').removeClass('ZX_Spart_puoff').addClass('ZX_Spart_pufull');
				}
				var t=(healtimer[i] - unix_timestamp()); if(t<1) { t=1; }
				$('#ZX_Spart_health'+i).html('<span class="bad">in '+t+'s</span>');
			}
			else {
				$('#ZX_Spart_health'+i).html(pi.ph.toFixed(1)+'%');
					$('#ZX_Spart_usepu'+i+' > .ZX_Spart_boost').removeClass('ZX_Spart_punoclick').addClass('ZX_Spart_puclick').removeClass('ZX_Spart_puoff').addClass('ZX_Spart_pufull');
					$('#ZX_Spart_usepu'+i+' > .ZX_Spart_kill').removeClass('ZX_Spart_punoclick').addClass('ZX_Spart_puclick').removeClass('ZX_Spart_puoff').addClass('ZX_Spart_pufull');
					$('#ZX_Spart_usepu'+i+' > .ZX_Spart_boost2').removeClass('ZX_Spart_puclick').addClass('ZX_Spart_punoclick').removeClass('ZX_Spart_pufull').addClass('ZX_Spart_puoff');
			}
			if(unix_timestamp()>healtimer[i]) {
				healtimer[i] = 0;
			}

			$('#ZX_Spart_score'+i).html(pi.sc);
			//team colors
			if (pi.tm == 1) {
				$('#ZX_Spart_op'+i).addClass('ZX_Spart_teamred');
			}
			else if (pi.tm == 2) {
				$('#ZX_Spart_op'+i).addClass('ZX_Spart_teamblue');
			}
			else {
				$('#ZX_Spart_op'+i).removeClass('ZX_Spart_teamblue').removeClass('ZX_Spart_teamred');
			}
			// team score
			if(pi.tm) {
				tscore[pi.tm]+=pi.sc;
			}
			
			var puhtml='';
			if(pi.pu>1) { puhtml+='<span class="ZX_Spart_defsh">&nbsp;</span> '; }
			if(pi.pu%2==1) { puhtml+='<span class="ZX_Spart_offsh">&nbsp;</span> '; }
			$('#ZX_Spart_pu'+i).html(puhtml);
		}
		// update teamscore
		if(data.ti) {
			if(data.ti["1"] && data.ti["2"]) {
				tscore["1"]+=2000 * data.ti["1"].stars;
				tscore["2"]+=2000 * data.ti["2"].stars;
				var t1=tscore["1"], t2=tscore["2"];
				var s1='',s2='';
				if(data.ti["1"].stars==0) {
					s1=nostarimg;
				} else {
					for(var i=0;i<data.ti["1"].stars;i++) { s1+=starimg; }
				}
				if(data.ti["2"].stars==0) {
					s2=nostarimg;
				} else {
					for(var i=0;i<data.ti["2"].stars;i++) { s2+=starimg; }
				}

				if(meteam==1) {
					$('#ZX_Spart_teamscore').html('<span style="color:#ec2d2d;">Team Red (you)</span> score: <span class="'+(t1>=t2?'good':'bad')+'">'+t1+'</span> '+s1+' vs. <span style="color:#0099FF;">Team Blue</span> score: <span class="'+(t2>=t1?'good':'bad')+'">'+t2+'</span> '+s1);
				} else {
					$('#ZX_Spart_teamscore').html('<span style="color:#0099FF;">Team Blue (you)</span> score: <span class="'+(t2>=t1?'good':'bad')+'">'+t2+'</span> '+s2+' vs. <span style="color:#ec2d2d;">Team Red</span> score: <span class="'+(t1>=t2?'good':'bad')+'">'+t1+'</span> '+s1);
				}
			}
		}
		if(data.mi) {
			$('#ZX_Spart_me_st').html(data.mi.st);
			//$('#ZX_Spart_me_ammo').html(data.mi.ammo);
//			$('#ZX_Spart_me_pst').html(data.mi.pst);
			if(data.mi.pui) {
				update_powerups(data.mi.pui);
			}
			$('#ZX_Spart_me_sr').html(data.mi.sr);

			if(currdata && currdata.mi) {
				if(data.mi.st>currdata.mi.stam+100) { // used used a stam refill
					loggerCentral('Used a stamina refill!','log');
					stam_on_start += (data.mi.st-currdata.mi.stam);
				}
			}
			$('#ZX_Spart_me_stused').html(stam_on_start - data.mi.st);
			if (Util.isset(data.mi.tpst)) {
				var stamarr = data.mi.tpst.split('|'), stai;
				for (stai=0;stai<stamarr.length;stai++) {
					var stampi = stamarr[stai].split(',');
					$('#ZX_Spart_stam'+stampi[0]).html(stampi[1]+'%');
				}
			}
		}

		// healing timer
		if(meid) {
			$('#ZX_Spart_me_health').removeClass('good').removeClass('bad').addClass(data.pi[meid].ph>0?'good':'bad').html(data.pi[meid].ph);
			if((data.pi[meid].ph==0) && (currdata.pi[meid].ph>0)) {
				healed_in=unix_timestamp()+10;
				clearInterval(healed_in_counter);
				healed_in_counter = setInterval(function(){
					if(unix_timestamp()>healed_in) {
						clearInterval(healed_in_counter);
						$('#ZX_Spart_healin').html('');
					} else {
						$('#ZX_Spart_healin').html('Healing in '+(healed_in - unix_timestamp())+'s');
					}
				},1000);
			} else {
				try {
					$('#ZX_Spart_healin').html('');
					clearInterval(healed_in_counter);
				} catch(e){ }
			}
		}

		for(i in data.pi) {
			if((data.pi[i].pid) && (!playerids[data.pi[i].pid])) {
				playerinfo[i]={ id:data.pi[i].pid };
				playerids[data.pi[i].pid]=i;
				if(data.pi[i].pid==User.id.substr(2)) {
					meid=i;
				}

				AjxRequest('xw_controller=Arena&xw_action=getSingleUserData&pid='+data.pi[i].pid+'&xw_client_id=8',function(msg){
					var id,json=JSON.parse(msg);
					for(id in json.data.result) {
						var nr=playerids[id];
						playerinfo[nr].name=json.data.result[id].name;
						playerinfo[nr].respect=json.data.result[id].playerRespect.replace(',','').replace('K','000');
						playerinfo[nr].diff=difficulty[json.data.result[id].defenseFlag+json.data.result[id].mafiaDefenseFlag];
						if(id == User.id.substr(2)) {
							$('#ZX_Spart_name'+nr).html('<span id="ZX_Spart_hover'+nr+'"><img src="'+json.data.result[id].pic+'" width="32" height="32" /><span class="good">Me!</span></span>');
							$('#ZX_Spart_diff'+nr).html('<div class="difficulty">-</div>');
							if(!stats.respect) { stats.respect_start=json.data.result[id].playerRespect.replace(',','').replace('K','000'); }
							$('#ZX_Spart_usepu'+nr).html(
								'<img src="'+powerups[2].pic+'" width="24" height="24" data-id="2" class="ZX_Spart_boost2 ZX_Spart_puoff ZX_Spart_punoclick ZX_Spart_punormal" title="Use health boost">'+
								'<img src="'+powerups[3].pic+'" width="24" height="24" data-id="3" class="ZX_Spart_boost ZX_Spart_pufull ZX_Spart_puclick ZX_Spart_punormal" title="Use meta flair">'+
								'<img src="'+powerups[4].pic+'" width="24" height="24" data-id="4" class="ZX_Spart_boost ZX_Spart_pufull ZX_Spart_puclick ZX_Spart_punormal" title="Use pain killer">'+
								'<img src="'+powerups[7].pic+'" width="24" height="24" data-id="7" class="ZX_Spart_boost ZX_Spart_pufull ZX_Spart_puclick ZX_Spart_punormal" title="Use reflector">'
							);
						}
						else {
							var m;
							if(m=/\d+_(\d+)_\d+/.exec(json.data.result[id].pic)) {
								var fb=(friendlist[m[1]]?' <img width="12" height="12" title="Facebook Friend: '+friendlist[m[1]]+'" src="http://www.facebook.com/favicon.ico">':'');
								$('#ZX_Spart_name'+nr).html('<span id="ZX_Spart_hover'+nr+'"><img src="'+json.data.result[id].pic+'" width="32" height="32" /><a href="https://www.facebook.com/'+m[1]+'" target="_blank">'+playerinfo[nr].name+fb+'</a></span>');
							} else {
								$('#ZX_Spart_name'+nr).html('<span id="ZX_Spart_hover'+nr+'"><img src="'+json.data.result[id].pic+'" width="32" height="32" />'+playerinfo[nr].name+'</span>');
							}
							$('#ZX_Spart_name'+nr).append('<span data-id="'+id+'" id="ZX_Spart_infobox'+nr+'" style="display:none;position:absolute;border:2px white solid;background-color:#222;padding:5px;border-radius:5px;">loading...</span>');
							$('#ZX_Spart_diff'+nr).html('<div class="difficulty">'+playerinfo[nr].diff+'</div>');
							var target='https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/leaderboard/leaderboardTarget.png';
							var defense='https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-defense_04.gif';
							$('#ZX_Spart_usepu'+nr).html(
								'<img src="'+powerups[5].pic+'" width="24" height="24" data-nr="'+nr+'" data-id="5" class="ZX_Spart_boost ZX_Spart_pufull ZX_Spart_puclick ZX_Spart_punormal" title="Nuke opponent (Kamikaze)">'+
								'<img src="'+powerups[6].pic+'" width="24" height="24" data-nr="'+nr+'" data-id="6" class="ZX_Spart_boost ZX_Spart_pufull ZX_Spart_puclick ZX_Spart_punormal" title="Use drain on opponent">'+
								'<img src="'+target+'" width="24" height="24" data-nr="'+nr+'"  class="ZX_Spart_kill ZX_Spart_pufull ZX_Spart_puclick ZX_Spart_punormal" title="Hit this player until dead" >'+
								'<img src="'+defense+'" width="24" height="24" data-nr="'+nr+'"  class="ZX_Spart_protect ZX_Spart_puhalf ZX_Spart_puclick ZX_Spart_punormal" title="Do not attack this player (click to enable, click again to disable)" >'


							);
						}
						$('#ZX_Spart_name'+nr).append('<span data-id="'+id+'" id="ZX_Spart_infobox'+nr+'" style="display:none;position:absolute;border:2px white solid;background-color:#222;padding:5px;border-radius:5px;">loading...</span>');

						$('#ZX_Spart_respect'+nr).html(playerinfo[nr].respect);
						$('#ZX_Spart_hover'+nr).hover(function(event){
							var num=this.id.substr(14);
							var id=$('#ZX_Spart_infobox'+num).attr('data-id');
							$('#ZX_Spart_infobox'+num).css("top",event.pageY+'px').css("left",(event.pageX-100)+'px');
							if(!$('#ZX_Spart_infobox'+num).attr('spdone')) {
								$('#ZX_Spart_infobox'+num).html('Profile loading...');
								load_player_profile(id,num);
							}
							$('#ZX_Spart_infobox'+num).show();
						},function(){
							var num=this.id.substr(14);
							$('#ZX_Spart_infobox'+num).hide();
						});
						
						
						/* intervene, protect */
						$('#ZX_Spart_usepu'+nr+' > .ZX_Spart_protect').click(function(){
							var pnr=$(this).attr('data-nr');
							if(protect[pnr]) {
								delete protect[pnr];
								$(this).removeClass('ZX_Spart_pufull').addClass('ZX_Spart_puhalf');
							} else {
								protect[pnr] = 1;
								$(this).removeClass('ZX_Spart_puhalf').addClass('ZX_Spart_pufull');
							}
						});
						
						/* intervene, kill */
						$('#ZX_Spart_usepu'+nr+' > .ZX_Spart_kill').click(function(){
							if($(this).hasClass('ZX_Spart_puclick')) { // only when active
								var pnr=$(this).attr('data-nr');
								if(powerup_command.target==pnr) { // turn off
									$(this).removeClass('ZX_Spart_puactive').addClass('ZX_Spart_punormal');
									powerup_command.target=undefined;
								} else if (powerup_command.target===undefined) { // no target yet
									$(this).removeClass('ZX_Spart_punormal').addClass('ZX_Spart_puactive');
									powerup_command.target=pnr;
								} else { // switch target
									$('#ZX_Spart_usepu'+powerup_command.target+' > img.ZX_Spart_kill').removeClass('ZX_Spart_puactive').addClass('ZX_Spart_punormal');
									$(this).removeClass('ZX_Spart_punormal').addClass('ZX_Spart_puactive');
									powerup_command.target=pnr;
								}
							}
						});
						
						/* intervene, boost */
						$('#ZX_Spart_usepu'+nr+' > .ZX_Spart_boost,#ZX_Spart_usepu'+nr+' > .ZX_Spart_boost2').click(function(){
							//console.log('click');
							if($(this).hasClass('ZX_Spart_puclick')) { // only when active
								var puid=$(this).attr('data-id');
								var pnr=$(this).attr('data-nr');
								$('.ZX_Spart_boost.ZX_Spart_puactive').removeClass('ZX_Spart_puactive').addClass('ZX_Spart_punormal');
								$(this).removeClass('ZX_Spart_punormal').addClass('ZX_Spart_puactive');
								powerup_command.active = puid;
								powerup_command.target = pnr;
							}
						});
					}
				});
			}

			if(!meteam) {
				if(data.pi[i] && (data.pi[i].pid==User.id.substr(2))) {
					if(data.pi[i].tm!=0) {
						meteam=data.pi[i].tm;
						//log('found team:'+meteam);
					}
				}			
			}
		}
		// sort player and rank
		var rank=[];
		for(i in playerinfo) {
			rank.push(i);
		}
		try {
			rank.sort(function(a,b){return cmp(data.pi[a].sc, data.pi[b].sc);});
		} catch (notyetstartederror) {}
		for(i=0;i<rank.length;i++){
			if(!$('#ZX_Spart_sortplayer').is(':checked')) {
				if(!over_table) {
					$('#ZX_Spart_table').append($('#ZX_Spart_op'+rank[i]));
				}
			}
			$('#ZX_Spart_rank'+rank[i]).html('#'+(i+1));
		}
		// save old
		currdata=data;
	}	

	function update_powerups(pui) {
		var html='<table><tr>';
		var i,pups=pui.split('|');
		for(i=0;i<pups.length;i++) {
			var pup=pups[i].split(',');
			var m=(pup[0].indexOf('-')===0);
			pup[0]=Math.abs(pup[0]);
			poweruplist[pup[0]]={ num:pup[2],cooldown:pup[1],type:m }
			if((powerup_command.count[pup[0]]!=pup[2]) && (powerup_command.active==pup[0])) {
				powerup_command.active=-1;
				$('.ZX_Spart_boost.ZX_Spart_puactive').removeClass('ZX_Spart_puactive').addClass('ZX_Spart_punormal');
			}
			powerup_command.count[pup[0]]=pup[2];
		}
		for(i in powerups) {
			if((poweruplist[i].cooldown>0) && (i!=5)) {
				html+='<td valign=top style="text-align:center;"><img class="ZX_Spart_notusepowerup" data-id="'+i+'" src="'+powerups[i].pic+'" title="'+powerups[i].name+'" width="60" height="60" /><br />&times'+poweruplist[i].num;
				html+='<br /><span title="On cooldown or active">A/C</span> '+poweruplist[i].cooldown+'s</span>';
			} else if (powerup_command.active==i) {
				html+='<td valign=top style="text-align:center;"><img class="ZX_Spart_notusepowerup" data-id="'+i+'" src="'+powerups[i].pic+'" title="'+powerups[i].name+'" width="60" height="60" /><br />&times'+poweruplist[i].num+
				'<br /><span title="Firing (sending command to server)">Fire</span>';
			} else {
				html+='<td valign=top style="text-align:center;"><img class="ZX_Spart_usepowerup" data-id="'+i+'" src="'+powerups[i].pic+'" title="'+powerups[i].name+'" width="60" height="60" /><br />&times'+poweruplist[i].num;
				html+='<br /><span id="ZX_Spart_pustatus'+i+'"></span>';
			}
			html+='</td>';
		}
		html+='</table>';
		if(poweruplist[5].cooldown>0) {
			powerup_status.kami_active = true;
			powerup_status.kami_used = true;
		}


		$('#ZX_Spart_powerups').html(html);
		$('.ZX_Spart_usepowerup').click(function(){
			var id=$(this).attr('data-id');
			loggerCentral('Using powerup: '+powerups[id].name,'log');
			$('#ZX_Spart_pustatus'+id).html('<span title="Firing (sending command to server)">Fire</span>');
			use_powerup(id);
			return false;
		});
	}

	function getdiff(now,old){
		if(!old) { return ''; }
		if(parseInt(old)<parseInt(now)) {
			return ' (<span class="good">+'+(parseInt(now)-parseInt(old))+'</span>)';
		} else {
			return '';
		}
	}	
	
	function create_user_data(text) {
		var user_fields = [];
		var user_info = [];
		text = text.replace('\\u00a3',"\u00a3");
		text = text.replace('\\u00a2',"\u00a2");
		user_f_exp = /user_fields\['(\w+)'\].*?"(.*?)"/g;
		user_i_exp = /user_info\['(\w+)'\].*?"(.*?)"/g;
		while ((user_f = user_f_exp.exec(text)) != null) {
			user_fields[user_f[1]] = (Util.is_integer(user_f[2]) ? parseInt(user_f[2]) : user_f[2]);
		}
		while ((user_i = user_i_exp.exec(text)) != null) {
			user_info[user_i[1]] = (Util.is_integer(user_i[2]) ? parseInt(user_i[2]) : user_i[2]);
		}
		return [user_fields,user_info];
	}
	
	function set_progress_bar(value,of,text){
		var pc=100-parseInt(value/of*100);
		if(pc<0) { pc=0; }
		if(pc>100) { pc=100; }
		
		if($('#spartacusbar').length>0) {
			$('#spartacusbar > div').css('width',pc+'%');
			$('#spartacusbar p').text(text);

			if(pc>=88) {
				$('#spartacusbar').removeClass('gold').addClass('ruby');
			} else {
				$('#spartacusbar').removeClass('ruby').addClass('gold');
			}
		} else {
			$('#ZX_Spart_timeleftbar').html(''+
				'<div class="bossInfo">'+
				'<div style="position:relative; height:25px; ">'+
				'<div id="spartacusbar" class="progressBar gold dark_border" style="width:488px; float:left;">'+
				'<div style="width: '+pc+'%;"></div><p style="text-align:center;">'+text+'</p>'+
				'<div style="width: '+pc+'%;"><p style="text-align:center;color:#FFFFFF;">'+text+'</p></div></div>'+
				'</div>'+
				'<div class="progBackground" style="display: none;"></div>'+
				'<div class="clearfix" style="clear:both;"></div></div>');
		}
	}
	
	function display_all_stats(){
		var html='';
		html+='Total arenas: '+stats.arenas+' ';
		html+='[';
		html+=stats.ranks[0]+'&times1st, ';
		html+=stats.ranks[1]+'&times2nd, ';
		html+=stats.ranks[2]+'&times3rd, ';
		html+=stats.ranks[3]+'&times4th, ';
		html+=stats.ranks[4]+'&times5th, ';
		html+=stats.ranks[5]+'&times6th';
		html+=']<br />';

		html+='Respect: <span class="respect">'+stats.respect+' ('+sdiff(stats.respect - stats.respect_start)+')</span> ';
		if(stats.crests) {
			html+='Crests: <span class="arena_mastery_crests">'+sdiff(stats.crests)+'</span> ';
		}
		html+='<span class="experience" title="XP earned">'+stats.xp+'</span> ';
		html+='<span class="attack" title="Score/Damage done">'+stats.score+'</span> ';
		html+='<span class="stamina" title="Stamina spent">'+stats.stamina+'</span> ';
		html+='<span class="experience" title="XP/Stamina">'+(stats.stamina==0?0:(stats.xp/stats.stamina).toFixed(2))+'</span> ';
		html+='<span class="attack" title="Damage/Stamina">'+(stats.stamina==0?0:(stats.score/stats.stamina).toFixed(2))+'</span> ';
		if(stats.stars) {
			html+='<span class="good">'+starimg+stats.stars+'</span> '
		}
		$('#ZX_Spart_allstats').html(html);
	}	
	
	function sdiff(num,color) {
		if(num==0) {
			return '&plusmn;0';
		} else if(num>0) {
			return '+'+num;
		} else {
			return num;
		}
	}
	function cmp(v1,v2){
		return (v1>v2?-1:(v1<v2?1:0));
	}

	var Ping = {
		inUse:false,
		start:0,
		ping:function(ip, callback) {
			if(!this.inUse) {

				this.inUse = true;
				this.callback = callback
				this.ip = ip;

				var _that = this;

				this.img = new Image();

				this.img.onload = function() {_that.good();};
				this.img.onerror = function() {_that.good();};

				this.start = (new Date()).getTime();
				this.img.src = "http://" + ip + '?id='+Math.random(4);
				this.timer = setTimeout(function() { _that.bad();}, 1500);
			}
		},
		good:function(){
			if(this.inUse) {
				this.inUse = false;
				this.callback((new Date()).getTime()-this.start);
				clearTimeout(this.timer);
			}
		},
		bad:function(){
			if(this.inUse) {
				this.inUse = false;
				this.callback(-1);
			}
		}
	}	
	
	function min(a,b){
		return a<b?a:b;
	}
	
	function max(a,b){
		return a>b?a:b;
	}
	
	function imgurl(img,w,h,a) {
		return '<img src="http://mwfb.static.zgncdn.com/mwfb/graphics/'+img+'" width="'+w+'" height="'+h+'" title="'+a+'" alt="'+a+'" align="absmiddle">';
	}
	
	function commas(s) {
		var d;
		while (d=/(-)?(\d+)(\d{3}.*)/.exec(s)) {
			s = (d[1]?d[1]+d[2]+','+d[3]:d[2]+','+d[3]);
		}
		return s;
	}
	
	function compare(a,b) {
		if (a==b) { return 0; }
		if (a>b) { return -1; }
		return 1;
	}

	function load_friendlist(){
		FB.api('/me/friends',function(data){ 
			var i;
			for(i=0;i<data.data.length;i++) {
				friendlist[data.data[i].id]=data.data[i].name;
			} 
			loggerCentral('Friendlist load complete.','log');
		});
	}
	
	function update_game_ui_sp(object) {
		if (Util.isset(object.user_fields)) {
			user_fields_update(object.user_fields);
			user_info_update(object.user_fields, object.user_info);
			if (Util.isset(object.user_fields.zmc_event_count)) {
				$('#zmc_event_count').text(object.user_fields.zmc_event_count);
			}
		}
		if (Util.isset(object.questData)) {
			MW.QuestBar.update(object.questData);
		}
	}	

	function getStats(handler) {
		AjxRequest('xw_controller=propertyV2&xw_action=createData&xw_city=7&tmp=&cb=&xw_person='+User.id.substr(2)+'&mwcom=&city=7&xw_client_id=8',function(msg){
			var data = JSON.parse(msg);
			update_game_ui_sp(data);
			if(handler) { handler(); }
		});
	}	
	
	function check_levelup(msg) {
		if(msg.indexOf('You are now LEVEL')!=-1) {
			loggerCentral('<span class="good">Levelup!</span>','log');
			var code=msg.re('(setTimeout.*\\,\\s10\\)\\;)');
			eval(code);
			grab_bonus();
		}
	}

/*asd*/	
	function parse_loot(msg){
		window.eikea=msg;
		var $msg=$('<div>'+msg+'</div>');
		var rewards={},arena={};
		var mobfury = false;
		if ($msg.find('div.team-status').length > 0) {
			mobfury = true;
			rewards.xp = parseInt($msg.find('div.xp-earned span.value').text()) || 0;
			rewards.respect = parseInt($msg.find('div.respect-earned span.value').text()) || 0;
		}
		else {
			rewards.xp = parseInt($msg.find('.xp_earned > .value').text()) || 0;
			rewards.respect = parseInt($msg.find('.respect_earned > .value:first').text()) || 0;
		}
		if($msg.find('.respect_earned > .label:last').text().indexOf('Crests')!=-1) {
			rewards.crests=parseInt($msg.find('.respect_earned > .value:last').text()) || 0;
		}
		rewards.stam_cur=parseInt($msg.find('.stamina_stats > .current').text());
		rewards.stam_total=parseInt($msg.find('.stamina_stats > span:last').text());
		if (mobfury) {
			if($msg.find('div.team-board.winner').find('li.myself').length > 0) {
				rewards.rank = 1;
			}
			else {
				rewards.rank = 6;
			}
			if($msg.find('.team-red .myself').length>0) {
				rewards.stars=$msg.find('.team-red .gold-star').length;
			} else {
				rewards.stars=$msg.find('.team-blue .gold-star').length;
			}
		}else {
			rewards.rank = $msg.find('.rank_holder > .position').text();
		}
		if(currdata) {
			rewards.stamused=(stam_on_start - currdata.mi.st);
			rewards.currst = currdata.mi.st;
		}
		rewards.ratio=(rewards.xp / rewards.stamused).toFixed(2);
		rewards.loot=[];
		rewards.points=parseInt($('#ZX_Spart_score'+meid).text());
		
		var loot_strings=[];
		$($msg.find('#your_reward_list > .arena_fight_rewards_item_container')).each(function(){
			var loot = {};
			loot.name = $(this).find('.arena_reward_items_bg > .name').text().trim() || $(this).find('.arena_reward_items_special_bg > .name').text().trim();
			loot.id = $(this).find('.arena_reward_items_bg img').attr('item_id') || false;
			loot.src = $(this).find('.arena_reward_items_bg img').attr('src') || $(this).find('.arena_reward_items_special_bg img').attr('src');
			loot.quantity = parseInt($(this).find('.qty').text().trim().substr(2)) || 1;
			loot.attack = parseInt($(this).find('.attack').text().trim()) || 0;
			loot.defense = parseInt($(this).find('.defense').text().trim()) || 0;
			rewards.loot.push(loot);
			loot_strings.push('<img src="'+loot.src+'" class="item_with_preview" item_id="'+loot.id+'" width="16" height="16">'+loot.name+' <span class="good">&times;'+loot.quantity+'</span> ');
			add_loot(loot);
		});
		if(rewards.crests){
			var loot={ name:"Crests", src:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/crestlogo_16.png",quantity:rewards.crests };
			rewards.loot.push(loot);
			loot_strings.unshift('<img src="'+loot.src+'" class="item_with_preview" item_id="'+loot.id+'" width="16" height="16">'+loot.name+' <span class="good">&times;'+loot.quantity+'</span> ');
			add_loot(loot);
		}
		if(rewards.stars) {
			var loot={ name:"Stars", src:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/TeamVSTeam/result_star_filled.png",quantity:rewards.stars };
			rewards.loot.push(loot);
			loot_strings.unshift('<img src="'+loot.src+'" width="16" height="16">'+loot.name+' <span class="good">&times;'+loot.quantity+'</span> ');
			add_loot(loot);
		}
		// console.log(rewards);
		loggerCentral('Result: #'+rewards.rank+' <span class="experience">'+rewards.xp+' ('+rewards.ratio+')</span> <span class="respect">'+(rewards.respect>0?'+':'')+rewards.respect+'</span> '+loot_strings.join(''), 'log');
		write_loot();
		update_crests();
		
		var logline='';
		var opponents=0, opponentname='',name='',score=0,resp=0,pos=1;
		if (mobfury) {
			//Team Red
			logline += '[<span class="ZX_Spart_teamred"><strong>Team Red</strong></span>] ';
			$($msg.find('div.team-red .standings_list')).each(function(){
				name = $(this).find('.name').text();
				score = $(this).find('.score').text();
				resp = $(this).find('.respect_wrapper').html();
				logline += pos+'. '+name+' <span class="respect">'+resp+'</span> Score: '+score+' - ';
				pos++;
			});
			//Team Blue
			logline += ' [<span class="ZX_Spart_teamblue"><strong>Team Blue</strong></span>] ';
			pos = 1;
			$($msg.find('div.team-blue .standings_list')).each(function(){
				name = $(this).find('.name').text();
				score = $(this).find('.score').text();
				resp = $(this).find('.respect_wrapper').html();
				logline += pos+'. '+name+' <span class="respect">'+resp+'</span> Score: '+score+' - ';
				pos++;
			});
			arena.teamred = parseInt($msg.find('#team-red-score').text()) || 0;
			arena.teamblue = parseInt($msg.find('#team-blue-score').text()) || 0;
			arena.type = 'mobfury';
			opponentname = 'Mob Fury';
			stats.respect = parseInt($msg.find('li.standings_list.myself div.respect_wrapper').html());
		}else {
			$($msg.find('.standings_list')).each(function(){
				var pos=$(this).find('.pos').text();
				var name=$(this).find('.name').text();
				var resp=$(this).find('.respect_wrapper').html();
				var powerups='';
				$(this).find('.powerups_used img').each(function(){
					powerups+='<img src="'+this.src+'" width="16" height="16" />';
				});
				logline+=pos+'. '+name+' <span class="respect">'+resp+'</span> '+powerups+' ';
				if(pos==parseInt(rewards.rank)) { stats.respect=parseInt(resp); }
				opponents++;
				if(!$(this).hasClass('its_me') || !$(this).hasClass('myself')) { opponentname=name; }
			});
		}
		loggerCentral(logline, 'log');

		// arena list
		arena.rank = parseInt(rewards.rank);
		arena.stam = rewards.stamused>0?rewards.stamused:0;
		arena.points = rewards.points;
		arena.crests = rewards.crests;
		arena.opponents = (mobfury ? 1 : opponents);
		arena.opponentname = opponentname;
		arena.diff = '';
		arena.currst = rewards.currst;
		$('span[id*="spartacus_diff"]').each(function(){arena.diff+=$(this).text().substr(0,1);})		
		arenalist.push(arena);
		//write_arenas();
		check_levelup(msg);
		
		stats.stamina+=rewards.stamused;
		stats.xp+=rewards.xp;
		stats.arenas++;
		if(rewards.stars) {
			stats.stars+=rewards.stars;
		}
		stats.ranks[parseInt(rewards.rank)-1]++;
		stats.crests+=rewards.crests;
		stats.score+=rewards.points;
	}

	function add_loot(item) {
		var id = (Util.isset(item.id) ? item.id : item.name);
		if (typeof looted[id] == 'object') {
			looted[id].quantity += item.quantity;
		}else {
			looted[id] = {
				"id": id, "name": item.name, "src": item.src, "quantity": item.quantity, "attack":item.attack, "defense":item.defense
			}
		}
	}

	function sort_loot(){
		var x,list = [];
		for (x in looted) {
			list.push(x);
		}
		list.sort(function(a,b){
			if(looted[a].name=="Ices") { return -1; }
			if(looted[b].name=="Ices") { return 1; }
			if(looted[a].name=="Crests") { return -1; }
			if(looted[b].name=="Crests") { return 1; }
			if(looted[a].name=="Stars") { return -1; }
			if(looted[b].name=="Stars") { return 1; }
			return compare(max(looted[a].attack,looted[a].defense),max(looted[b].attack,looted[b].defense));
		});
		return list;
	}

	function write_loot() {
		var sorted=sort_loot();
		var loothtml = '<table>';
		for (i=0;i<sorted.length;i++) {
			var loot = looted[sorted[i]];
			var image = '<img src="'+loot.src+'" class="item_with_preview" item_id="'+loot.id+'" title="'+loot.name+'" width="16" height="16" />';
			if (itemdatabase[loot.id]) {
				var loot2 = itemdatabase[loot.id];
				var attack = '', defense = '', improves = false, improve = '', stopat = '';
				if (loot2.attack > 0) {
					attack = '['+loot2.attack+'A';
					if(worstitems[itemdatabase[loot.id].type].att<loot2.attack) {
						improves = true;
						improve += '<span class="attack good">+'+(loot2.attack - worstitems[itemdatabase[loot.id].type].att)+'</span> ';
					}
				}
				if (loot2.defense > 0) {
					defense = loot2.defense+'D]';
					if(worstitems[itemdatabase[loot.id].type].def<loot2.defense) {
						improves = true;
						improve += '<span class="defense good">+'+(loot2.defense - worstitems[itemdatabase[loot.id].type].def)+'</span>';
					}
				}
				
				var have = loot.quantity;

				have = (loot2.quantity>0?' <span class="more_in">Have: '+(loot2.quantity+loot.quantity)+'</span>':'');
				loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td><td>'+image+'<span style="'+(improves?"color:yellow;":"")+'">'+loot2.name+'</td><td>'+attack+'</td><td>'+defense+'</span></td><td>'+improve+'</td><td>'+have+'</td><td><a href="#" class="ZX_Spart_stopatloot" data-id="'+escape(loot.id)+'">'+stopat+'</a></td></tr>';
			}
			else
			{
				if(loot.name=="Ices") {
					loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td></td><td><span style="color: #609AD1; font-weight:bold;">'+image+loot.name+'</span></td><td></tr>';
				} else if (loot.name=="Stars") {
					loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td></td><td><span style="color: yellow; font-weight:bold;">'+image+loot.name+'</span></td><td></tr>';
				} else {
					loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td></td><td>'+image+loot.name+'</td><td></tr>';
				}
			}
		}
		loothtml += '</table>';
		$('#ZX_Spart_lootlog').html(loothtml);	
	}

	function loadInventoryAAN() {
		User.clicks++;
		var preurl = '//'+zserver+'.mafiawars.zynga.com/mwfb/remote/html_server.php?';
		var params = {
			'ajax': 1,
			'xw_client_id': 8,
			'liteload': 1,
			'sf_xw_user_id': User.id,
			'sf_xw_sig': local_xw_sig,
			'xw_city': 1,
			'clicks': User.clicks
		};
		$.ajax({
			type: "POST",
			url: preurl+'xw_controller=inventory&xw_action=view&from_controller=inventory',
			data: params,
			cache: false,
			success: function(response){
				//itemdatabase = {};
				var ZyngaItems = jQuery.parseJSON(/var Items = \{\s+data: (\{.*?\})\};/.exec(response)[1]);
				worstitems = jQuery.parseJSON(/MW.WorstItemsModule.update\((\{.*\})\);/.exec(response)[1]);
				//Locations = jQuery.parseJSON(/var Locations = \{\s+data: (\{.*?\})\};/.exec(response)[1]);
				for (x in ZyngaItems) {
					ZyngaItems[x].combined = parseInt(ZyngaItems[x].attack+ZyngaItems[x].defense);
					itemdatabase[ZyngaItems[x].id] = ZyngaItems[x]; //{quantity: ZyngaItems[x].quantity}
				}
				loggerCentral('Inventory load complete.', 'log');
//				load_friendlist();
			},
			error: function(){
				loggerCentral('<span class="bad">Inventory Load failed!</span>', 'log');
//				load_friendlist();
			}
		});
	}
	
	getStats(function(){
		display_all_stats();
		loadInventoryAAN();
		load_friendlist();
		update_crests();
		set_progress_bar(0,0,'');
	});
	
	$('#ZX_Spart_rewards').click(function(){
		get_rewards();
		return false;
	});
	$('.ZX_Spart_att').click(function(){
		attack($(this).attr('data-id'),1);
		return false;
	});
	$('#ZX_Spart_toggleloot').click(function(){
		$('.ZX_Spart_lootlog').toggle();
		//write_loot();
		return false;
	});
	$('#ZX_Spart_togglearenas').click(function(){
		$('.ZX_Spart_arenalog').toggle();
		//write_loot();
		return false;
	});
	$('#ZX_Spart_stopon').change(function(){
		if(this.selectedIndex>1) {
			$('#ZX_Spart_show_stopon_value').show();
		} else {
			$('#ZX_Spart_show_stopon_value').hide();
		}
	}).trigger('change');
	$('#ZX_Spart_arenatype').change(function(){
		if($('#ZX_Spart_arenatype').val() == "hw") {
			$('#Arena_Switch_O').show();
		} else {
			$('#Arena_Switch_O').hide();
		}
	}).trigger('change');
	$('#ZX_Spart_restart_stam').change(function(){
		if(this.checked) {
			$('#ZX_Spart_show_restart_stam').show();
		} else {
			$('#ZX_Spart_show_restart_stam').hide();
		}
	}).trigger('change');
	$('#ZX_Spart_table').hover(function(){
		over_table = true;
		$('#ZX_Spart_table').css('border-color','#444');
		$('#ZX_Spart_lockrank').show();
	},function(){
		over_table = false;
		$('#ZX_Spart_table').css('border-color','black');
		$('#ZX_Spart_lockrank').hide();
		
	});	
	
	// by Eike
	String.prototype.re = function(regex){
		var r=new RegExp(regex);
		var m;
		if(m=r.exec(this)) {
			return m[1];
		} else {
			return '';
		}
	}	
	
	/*add analytics*/
	function loadContent(file) {
		var head=document.getElementsByTagName('head').item(0);
		var scriptTag=document.getElementById('loadScript');
		if(scriptTag)head.removeChild(scriptTag);
		script=document.createElement('script');
		script.src=file;
		script.type='text/javascript';
		script.id='loadScript';
		head.appendChild(script);
		setTimeout(load,1000);
	}
	loadContent('http://www.google-analytics.com/ga.js');
	function load() {
		try {
			var pageTracker=_gat._getTracker("UA-35022618-1");
			pageTracker._trackPageview("/Zangano v"+Zangano.Version);
		} catch(err){}
	}
	/*end analytics*/	
	
	function logit(msg) {
		setTimeout(function() {
			throw new Error(msg);
		}, 0);
	}